Changeset 1377 in subversion
- Timestamp:
- May 12, 2008 8:19:32 AM (5 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 17 edited
-
CHANGELOG (modified) (1 diff)
-
program/lib/DB.php (modified) (16 diffs)
-
program/lib/DB/common.php (modified) (20 diffs)
-
program/lib/DB/dbase.php (modified) (7 diffs)
-
program/lib/DB/fbsql.php (modified) (10 diffs)
-
program/lib/DB/ibase.php (modified) (14 diffs)
-
program/lib/DB/ifx.php (modified) (8 diffs)
-
program/lib/DB/msql.php (modified) (9 diffs)
-
program/lib/DB/mssql.php (modified) (12 diffs)
-
program/lib/DB/mysql.php (modified) (11 diffs)
-
program/lib/DB/mysqli.php (modified) (15 diffs)
-
program/lib/DB/oci8.php (modified) (20 diffs)
-
program/lib/DB/odbc.php (modified) (4 diffs)
-
program/lib/DB/pgsql.php (modified) (14 diffs)
-
program/lib/DB/sqlite.php (modified) (9 diffs)
-
program/lib/DB/storage.php (modified) (4 diffs)
-
program/lib/DB/sybase.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r1375 r1377 1 1 CHANGELOG RoundCube Webmail 2 2 --------------------------- 3 4 2008/05/12 (alec) 5 - Updated PEAR::DB package to version 1.7.13 3 6 4 7 2008/05/10 (alec) -
trunk/roundcubemail/program/lib/DB.php
r12 r1377 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$ … … 425 425 * @author Tomas V.V.Cox <cox@idecnet.com> 426 426 * @author Daniel Convissor <danielc@php.net> 427 * @copyright 1997-200 5The PHP Group427 * @copyright 1997-2007 The PHP Group 428 428 * @license http://www.php.net/license/3_0.txt PHP License 3.0 429 * @version Release: @package_version@429 * @version Release: 1.7.13 430 430 * @link http://pear.php.net/package/DB 431 431 */ … … 468 468 } 469 469 470 @$obj = &new $classname;470 @$obj = new $classname; 471 471 472 472 foreach ($options as $option => $value) { … … 545 545 } 546 546 547 @$obj = &new $classname;547 @$obj = new $classname; 548 548 549 549 foreach ($options as $option => $value) { … … 556 556 $err = $obj->connect($dsninfo, $obj->getOption('persistent')); 557 557 if (DB::isError($err)) { 558 $err->addUserInfo($dsn); 558 if (is_array($dsn)) { 559 $err->addUserInfo(DB::getDSNString($dsn, true)); 560 } else { 561 $err->addUserInfo($dsn); 562 } 559 563 return $err; 560 564 } … … 573 577 function apiVersion() 574 578 { 575 return ' @package_version@';579 return '1.7.13'; 576 580 } 577 581 … … 626 630 $manips = 'INSERT|UPDATE|DELETE|REPLACE|' 627 631 . 'CREATE|DROP|' 628 . 'LOAD DATA|SELECT .* INTO |COPY|'632 . 'LOAD DATA|SELECT .* INTO .* FROM|COPY|' 629 633 . 'ALTER|GRANT|REVOKE|' 630 634 . 'LOCK|UNLOCK'; … … 809 813 $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp'; 810 814 $proto_opts = rawurldecode($proto_opts); 815 if (strpos($proto_opts, ':') !== false) { 816 list($proto_opts, $parsed['port']) = explode(':', $proto_opts); 817 } 811 818 if ($parsed['protocol'] == 'tcp') { 812 if (strpos($proto_opts, ':') !== false) { 813 list($parsed['hostspec'], 814 $parsed['port']) = explode(':', $proto_opts); 815 } else { 816 $parsed['hostspec'] = $proto_opts; 817 } 819 $parsed['hostspec'] = $proto_opts; 818 820 } elseif ($parsed['protocol'] == 'unix') { 819 821 $parsed['socket'] = $proto_opts; … … 849 851 850 852 // }}} 853 // {{{ getDSNString() 854 855 /** 856 * Returns the given DSN in a string format suitable for output. 857 * 858 * @param array|string the DSN to parse and format 859 * @param boolean true to hide the password, false to include it 860 * @return string 861 */ 862 function getDSNString($dsn, $hidePassword) { 863 /* Calling parseDSN will ensure that we have all the array elements 864 * defined, and means that we deal with strings and array in the same 865 * manner. */ 866 $dsnArray = DB::parseDSN($dsn); 867 868 if ($hidePassword) { 869 $dsnArray['password'] = 'PASSWORD'; 870 } 871 872 /* Protocol is special-cased, as using the default "tcp" along with an 873 * Oracle TNS connection string fails. */ 874 if (is_string($dsn) && strpos($dsn, 'tcp') === false && $dsnArray['protocol'] == 'tcp') { 875 $dsnArray['protocol'] = false; 876 } 877 878 // Now we just have to construct the actual string. This is ugly. 879 $dsnString = $dsnArray['phptype']; 880 if ($dsnArray['dbsyntax']) { 881 $dsnString .= '('.$dsnArray['dbsyntax'].')'; 882 } 883 $dsnString .= '://' 884 .$dsnArray['username'] 885 .':' 886 .$dsnArray['password'] 887 .'@' 888 .$dsnArray['protocol']; 889 if ($dsnArray['socket']) { 890 $dsnString .= '('.$dsnArray['socket'].')'; 891 } 892 if ($dsnArray['protocol'] && $dsnArray['hostspec']) { 893 $dsnString .= '+'; 894 } 895 $dsnString .= $dsnArray['hostspec']; 896 if ($dsnArray['port']) { 897 $dsnString .= ':'.$dsnArray['port']; 898 } 899 $dsnString .= '/'.$dsnArray['database']; 900 901 /* Option handling. Unfortunately, parseDSN simply places options into 902 * the top-level array, so we'll first get rid of the fields defined by 903 * DB and see what's left. */ 904 unset($dsnArray['phptype'], 905 $dsnArray['dbsyntax'], 906 $dsnArray['username'], 907 $dsnArray['password'], 908 $dsnArray['protocol'], 909 $dsnArray['socket'], 910 $dsnArray['hostspec'], 911 $dsnArray['port'], 912 $dsnArray['database'] 913 ); 914 if (count($dsnArray) > 0) { 915 $dsnString .= '?'; 916 $i = 0; 917 foreach ($dsnArray as $key => $value) { 918 if (++$i > 1) { 919 $dsnString .= '&'; 920 } 921 $dsnString .= $key.'='.$value; 922 } 923 } 924 925 return $dsnString; 926 } 927 928 // }}} 851 929 } 852 930 … … 861 939 * @package DB 862 940 * @author Stig Bakken <ssb@php.net> 863 * @copyright 1997-200 5The PHP Group941 * @copyright 1997-2007 The PHP Group 864 942 * @license http://www.php.net/license/3_0.txt PHP License 3.0 865 * @version Release: @package_version@943 * @version Release: 1.7.13 866 944 * @link http://pear.php.net/package/DB 867 945 */ … … 908 986 * @package DB 909 987 * @author Stig Bakken <ssb@php.net> 910 * @copyright 1997-200 5The PHP Group988 * @copyright 1997-2007 The PHP Group 911 989 * @license http://www.php.net/license/3_0.txt PHP License 3.0 912 * @version Release: @package_version@990 * @version Release: 1.7.13 913 991 * @link http://pear.php.net/package/DB 914 992 */ … … 1090 1168 $object_class = $this->fetchmode_object_class; 1091 1169 } 1092 if ( $this->limit_from !== null) {1170 if (is_null($rownum) && $this->limit_from !== null) { 1093 1171 if ($this->row_counter === null) { 1094 1172 $this->row_counter = $this->limit_from; … … 1122 1200 $arr = (object) $arr; 1123 1201 } else { 1124 $arr = &new $object_class($arr);1202 $arr = new $object_class($arr); 1125 1203 } 1126 1204 } … … 1172 1250 $object_class = $this->fetchmode_object_class; 1173 1251 } 1174 if ( $this->limit_from !== null) {1252 if (is_null($rownum) && $this->limit_from !== null) { 1175 1253 if ($this->row_counter === null) { 1176 1254 $this->row_counter = $this->limit_from; … … 1254 1332 $i++; 1255 1333 } 1256 return$i;1334 $count = $i; 1257 1335 } else { 1258 return $this->dbh->numRows($this->result); 1259 } 1336 $count = $this->dbh->numRows($this->result); 1337 } 1338 1339 /* fbsql is checked for here because limit queries are implemented 1340 * using a TOP() function, which results in fbsql_num_rows still 1341 * returning the total number of rows that would have been returned, 1342 * rather than the real number. As a result, we'll just do the limit 1343 * calculations for fbsql in the same way as a database with emulated 1344 * limits. Unfortunately, we can't just do this in DB_fbsql::numRows() 1345 * because that only gets the result resource, rather than the full 1346 * DB_Result object. */ 1347 if (($this->dbh->features['limit'] === 'emulate' 1348 && $this->limit_from !== null) 1349 || $this->dbh->phptype == 'fbsql') { 1350 $limit_count = is_null($this->limit_count) ? $count : $this->limit_count; 1351 if ($count < $this->limit_from) { 1352 $count = 0; 1353 } elseif ($count < ($this->limit_from + $limit_count)) { 1354 $count -= $this->limit_from; 1355 } else { 1356 $count = $limit_count; 1357 } 1358 } 1359 1360 return $count; 1260 1361 } 1261 1362 … … 1350 1451 * @package DB 1351 1452 * @author Stig Bakken <ssb@php.net> 1352 * @copyright 1997-200 5The PHP Group1453 * @copyright 1997-2007 The PHP Group 1353 1454 * @license http://www.php.net/license/3_0.txt PHP License 3.0 1354 * @version Release: @package_version@1455 * @version Release: 1.7.13 1355 1456 * @link http://pear.php.net/package/DB 1356 1457 * @see DB_common::setFetchMode() -
trunk/roundcubemail/program/lib/DB/common.php
r12 r1377 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$ … … 41 41 * @author Tomas V.V. Cox <cox@idecnet.com> 42 42 * @author Daniel Convissor <danielc@php.net> 43 * @copyright 1997-200 5The PHP Group43 * @copyright 1997-2007 The PHP Group 44 44 * @license http://www.php.net/license/3_0.txt PHP License 3.0 45 * @version Release: @package_version@45 * @version Release: 1.7.13 46 46 * @link http://pear.php.net/package/DB 47 47 */ … … 121 121 */ 122 122 var $prepared_queries = array(); 123 124 /** 125 * Flag indicating that the last query was a manipulation query. 126 * @access protected 127 * @var boolean 128 */ 129 var $_last_query_manip = false; 130 131 /** 132 * Flag indicating that the next query <em>must</em> be a manipulation 133 * query. 134 * @access protected 135 * @var boolean 136 */ 137 var $_next_query_manip = false; 123 138 124 139 … … 425 440 function quoteSmart($in) 426 441 { 427 if (is_int($in) || is_double($in)) {442 if (is_int($in)) { 428 443 return $in; 444 } elseif (is_float($in)) { 445 return $this->quoteFloat($in); 429 446 } elseif (is_bool($in)) { 430 return $ in ? 1 : 0;447 return $this->quoteBoolean($in); 431 448 } elseif (is_null($in)) { 432 449 return 'NULL'; 433 450 } else { 451 if ($this->dbsyntax == 'access' 452 && preg_match('/^#.+#$/', $in)) 453 { 454 return $this->escapeSimple($in); 455 } 434 456 return "'" . $this->escapeSimple($in) . "'"; 435 457 } 436 458 } 437 459 460 // }}} 461 // {{{ quoteBoolean() 462 463 /** 464 * Formats a boolean value for use within a query in a locale-independent 465 * manner. 466 * 467 * @param boolean the boolean value to be quoted. 468 * @return string the quoted string. 469 * @see DB_common::quoteSmart() 470 * @since Method available since release 1.7.8. 471 */ 472 function quoteBoolean($boolean) { 473 return $boolean ? '1' : '0'; 474 } 475 476 // }}} 477 // {{{ quoteFloat() 478 479 /** 480 * Formats a float value for use within a query in a locale-independent 481 * manner. 482 * 483 * @param float the float value to be quoted. 484 * @return string the quoted string. 485 * @see DB_common::quoteSmart() 486 * @since Method available since release 1.7.8. 487 */ 488 function quoteFloat($float) { 489 return "'".$this->escapeSimple(str_replace(',', '.', strval(floatval($float))))."'"; 490 } 491 438 492 // }}} 439 493 // {{{ escapeSimple() … … 838 892 return $sth; 839 893 } 840 $ret = &$this->execute($sth, array_values($fields_values));894 $ret = $this->execute($sth, array_values($fields_values)); 841 895 $this->freePrepared($sth); 842 896 return $ret; … … 932 986 * 'filename.txt' 933 987 * ); 934 * $res = &$db->execute($sth, $data);988 * $res = $db->execute($sth, $data); 935 989 * </code> 936 990 * … … 961 1015 return $result; 962 1016 } else { 963 $tmp = &new DB_result($this, $result);1017 $tmp = new DB_result($this, $result); 964 1018 return $tmp; 965 1019 } … … 1042 1096 { 1043 1097 foreach ($data as $value) { 1044 $res = &$this->execute($stmt, $value);1098 $res = $this->execute($stmt, $value); 1045 1099 if (DB::isError($res)) { 1046 1100 return $res; … … 1155 1209 return $sth; 1156 1210 } 1157 $ret = &$this->execute($sth, $params);1211 $ret = $this->execute($sth, $params); 1158 1212 $this->freePrepared($sth, false); 1159 1213 return $ret; … … 1164 1218 return $result; 1165 1219 } else { 1166 $tmp = &new DB_result($this, $result);1220 $tmp = new DB_result($this, $result); 1167 1221 return $tmp; 1168 1222 } … … 1195 1249 return $query; 1196 1250 } 1197 $result = &$this->query($query, $params);1251 $result = $this->query($query, $params); 1198 1252 if (is_a($result, 'DB_result')) { 1199 1253 $result->setOption('limit_from', $from); … … 1230 1284 return $sth; 1231 1285 } 1232 $res = &$this->execute($sth, $params);1286 $res = $this->execute($sth, $params); 1233 1287 $this->freePrepared($sth); 1234 1288 } else { 1235 $res = &$this->query($query);1289 $res = $this->query($query); 1236 1290 } 1237 1291 … … 1294 1348 return $sth; 1295 1349 } 1296 $res = &$this->execute($sth, $params);1350 $res = $this->execute($sth, $params); 1297 1351 $this->freePrepared($sth); 1298 1352 } else { 1299 $res = &$this->query($query);1353 $res = $this->query($query); 1300 1354 } 1301 1355 … … 1345 1399 } 1346 1400 1347 $res = &$this->execute($sth, $params);1401 $res = $this->execute($sth, $params); 1348 1402 $this->freePrepared($sth); 1349 1403 } else { 1350 $res = &$this->query($query);1404 $res = $this->query($query); 1351 1405 } 1352 1406 … … 1361 1415 } else { 1362 1416 if (!array_key_exists($col, $row)) { 1363 $ret = &$this->raiseError(DB_ERROR_NOSUCHFIELD);1417 $ret = $this->raiseError(DB_ERROR_NOSUCHFIELD); 1364 1418 } else { 1365 1419 $ret = array($row[$col]); … … 1477 1531 } 1478 1532 1479 $res = &$this->execute($sth, $params);1533 $res = $this->execute($sth, $params); 1480 1534 $this->freePrepared($sth); 1481 1535 } else { 1482 $res = &$this->query($query);1536 $res = $this->query($query); 1483 1537 } 1484 1538 … … 1492 1546 1493 1547 if ($cols < 2) { 1494 $tmp = &$this->raiseError(DB_ERROR_TRUNCATED);1548 $tmp = $this->raiseError(DB_ERROR_TRUNCATED); 1495 1549 return $tmp; 1496 1550 } … … 1604 1658 } 1605 1659 1606 $res = &$this->execute($sth, $params);1660 $res = $this->execute($sth, $params); 1607 1661 $this->freePrepared($sth); 1608 1662 } else { 1609 $res = &$this->query($query);1663 $res = $this->query($query); 1610 1664 } 1611 1665 … … 1628 1682 1629 1683 if (DB::isError($row)) { 1630 $tmp = &$this->raiseError($row);1684 $tmp = $this->raiseError($row); 1631 1685 return $tmp; 1632 1686 } … … 2104 2158 2105 2159 // }}} 2160 // {{{ nextQueryIsManip() 2161 2162 /** 2163 * Sets (or unsets) a flag indicating that the next query will be a 2164 * manipulation query, regardless of the usual DB::isManip() heuristics. 2165 * 2166 * @param boolean true to set the flag overriding the isManip() behaviour, 2167 * false to clear it and fall back onto isManip() 2168 * 2169 * @return void 2170 * 2171 * @access public 2172 */ 2173 function nextQueryIsManip($manip) 2174 { 2175 $this->_next_query_manip = $manip; 2176 } 2177 2178 // }}} 2179 // {{{ _checkManip() 2180 2181 /** 2182 * Checks if the given query is a manipulation query. This also takes into 2183 * account the _next_query_manip flag and sets the _last_query_manip flag 2184 * (and resets _next_query_manip) according to the result. 2185 * 2186 * @param string The query to check. 2187 * 2188 * @return boolean true if the query is a manipulation query, false 2189 * otherwise 2190 * 2191 * @access protected 2192 */ 2193 function _checkManip($query) 2194 { 2195 if ($this->_next_query_manip || DB::isManip($query)) { 2196 $this->_last_query_manip = true; 2197 } else { 2198 $this->_last_query_manip = false; 2199 } 2200 $this->_next_query_manip = false; 2201 return $this->_last_query_manip; 2202 $manip = $this->_next_query_manip; 2203 } 2204 2205 // }}} 2106 2206 // {{{ _rtrimArrayValues() 2107 2207 -
trunk/roundcubemail/program/lib/DB/dbase.php
r12 r1377 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$ … … 40 40 * @author Tomas V.V. Cox <cox@idecnet.com> 41 41 * @author Daniel Convissor <danielc@php.net> 42 * @copyright 1997-200 5The PHP Group42 * @copyright 1997-2007 The PHP Group 43 43 * @license http://www.php.net/license/3_0.txt PHP License 3.0 44 * @version Release: @package_version@44 * @version Release: 1.7.13 45 45 * @link http://pear.php.net/package/DB 46 46 */ … … 189 189 * ); 190 190 * 191 * $db = &DB::connect($dsn, $options);191 * $db = DB::connect($dsn, $options); 192 192 * if (PEAR::isError($db)) { 193 193 * die($db->getMessage()); … … 215 215 * is the only way to find errors from the dbase extension. 216 216 */ 217 ini_set('track_errors', 1);217 @ini_set('track_errors', 1); 218 218 $php_errormsg = ''; 219 219 … … 274 274 // emulate result resources 275 275 $this->res_row[(int)$this->result] = 0; 276 $tmp = &new DB_result($this, $this->result++);276 $tmp = new DB_result($this, $this->result++); 277 277 return $tmp; 278 278 } … … 327 327 328 328 // }}} 329 // {{{ freeResult() 330 331 /** 332 * Deletes the result set and frees the memory occupied by the result set. 333 * 334 * This method is a no-op for dbase, as there aren't result resources in 335 * the same sense as most other database backends. 336 * 337 * @param resource $result PHP's query result resource 338 * 339 * @return bool TRUE on success, FALSE if $result is invalid 340 * 341 * @see DB_result::free() 342 */ 343 function freeResult($result) 344 { 345 return true; 346 } 347 348 // }}} 329 349 // {{{ numCols() 330 350 … … 369 389 370 390 // }}} 371 // {{{ quoteSmart() 372 373 /** 374 * Formats input so it can be safely used in a query 375 * 376 * @param mixed $in the data to be formatted 377 * 378 * @return mixed the formatted data. The format depends on the input's 379 * PHP type: 380 * + null = the string <samp>NULL</samp> 381 * + boolean = <samp>T</samp> if true or 382 * <samp>F</samp> if false. Use the <kbd>Logical</kbd> 383 * data type. 384 * + integer or double = the unquoted number 385 * + other (including strings and numeric strings) = 386 * the data with single quotes escaped by preceeding 387 * single quotes then the whole string is encapsulated 388 * between single quotes 389 * 391 // {{{ quoteBoolean() 392 393 /** 394 * Formats a boolean value for use within a query in a locale-independent 395 * manner. 396 * 397 * @param boolean the boolean value to be quoted. 398 * @return string the quoted string. 390 399 * @see DB_common::quoteSmart() 391 * @since Method available since Release 1.6.0 392 */ 393 function quoteSmart($in) 394 { 395 if (is_int($in) || is_double($in)) { 396 return $in; 397 } elseif (is_bool($in)) { 398 return $in ? 'T' : 'F'; 399 } elseif (is_null($in)) { 400 return 'NULL'; 401 } else { 402 return "'" . $this->escapeSimple($in) . "'"; 403 } 404 } 405 400 * @since Method available since release 1.7.8. 401 */ 402 function quoteBoolean($boolean) { 403 return $boolean ? 'T' : 'F'; 404 } 405 406 406 // }}} 407 407 // {{{ tableInfo() -
trunk/roundcubemail/program/lib/DB/fbsql.php
r12 r1377 19 19 * @author Frank M. Kromann <frank@frontbase.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$ … … 40 40 * @author Frank M. Kromann <frank@frontbase.com> 41 41 * @author Daniel Convissor <danielc@php.net> 42 * @copyright 1997-200 5The PHP Group42 * @copyright 1997-2007 The PHP Group 43 43 * @license http://www.php.net/license/3_0.txt PHP License 3.0 44 * @version Release: @package_version@44 * @version Release: 1.7.13 45 45 * @link http://pear.php.net/package/DB 46 46 * @since Class functional since Release 1.7.0 … … 172 172 $params); 173 173 } else { 174 ini_set('track_errors', 1);174 @ini_set('track_errors', 1); 175 175 $this->connection = @call_user_func_array($connect_function, 176 176 $params); 177 ini_set('track_errors', $ini);177 @ini_set('track_errors', $ini); 178 178 } 179 179 … … 230 230 // Determine which queries that should return data, and which 231 231 // should return an error code only. 232 if ( DB::isManip($query)) {232 if ($this->_checkManip($query)) { 233 233 return DB_OK; 234 234 } … … 321 321 function freeResult($result) 322 322 { 323 return @fbsql_free_result($result);323 return is_resource($result) ? fbsql_free_result($result) : false; 324 324 } 325 325 … … 354 354 function commit() 355 355 { 356 @fbsql_commit( );356 @fbsql_commit($this->connection); 357 357 } 358 358 … … 367 367 function rollback() 368 368 { 369 @fbsql_rollback( );369 @fbsql_rollback($this->connection); 370 370 } 371 371 … … 432 432 function affectedRows() 433 433 { 434 if ( DB::isManip($this->last_query)) {434 if ($this->_last_query_manip) { 435 435 $result = @fbsql_affected_rows($this->connection); 436 436 } else { … … 544 544 function modifyLimitQuery($query, $from, $count, $params = array()) 545 545 { 546 if (DB::isManip($query) ) {546 if (DB::isManip($query) || $this->_next_query_manip) { 547 547 return preg_replace('/^([\s(])*SELECT/i', 548 548 "\\1SELECT TOP($count)", $query); … … 554 554 555 555 // }}} 556 // {{{ quoteSmart() 557 558 /** 559 * Formats input so it can be safely used in a query 560 * 561 * @param mixed $in the data to be formatted 562 * 563 * @return mixed the formatted data. The format depends on the input's 564 * PHP type: 565 * + null = the string <samp>NULL</samp> 566 * + boolean = string <samp>TRUE</samp> or <samp>FALSE</samp> 567 * + integer or double = the unquoted number 568 * + other (including strings and numeric strings) = 569 * the data escaped according to FrontBase's settings 570 * then encapsulated between single quotes 571 * 556 // {{{ quoteBoolean() 557 558 /** 559 * Formats a boolean value for use within a query in a locale-independent 560 * manner. 561 * 562 * @param boolean the boolean value to be quoted. 563 * @return string the quoted string. 572 564 * @see DB_common::quoteSmart() 573 * @since Method available since Release 1.6.0 574 */ 575 function quoteSmart($in) 576 { 577 if (is_int($in) || is_double($in)) { 578 return $in; 579 } elseif (is_bool($in)) { 580 return $in ? 'TRUE' : 'FALSE'; 581 } elseif (is_null($in)) { 582 return 'NULL'; 583 } else { 584 return "'" . $this->escapeSimple($in) . "'"; 585 } 586 } 587 565 * @since Method available since release 1.7.8. 566 */ 567 function quoteBoolean($boolean) { 568 return $boolean ? 'TRUE' : 'FALSE'; 569 } 570 571 // }}} 572 // {{{ quoteFloat() 573 574 /** 575 * Formats a float value for use within a query in a locale-independent 576 * manner. 577 * 578 * @param float the float value to be quoted. 579 * @return string the quoted string. 580 * @see DB_common::quoteSmart() 581 * @since Method available since release 1.7.8. 582 */ 583 function quoteFloat($float) { 584 return $this->escapeSimple(str_replace(',', '.', strval(floatval($float)))); 585 } 586 588 587 // }}} 589 588 // {{{ fbsqlRaiseError() -
trunk/roundcubemail/program/lib/DB/ibase.php
r12 r1377 22 22 * @author Sterling Hughes <sterling@php.net> 23 23 * @author Daniel Convissor <danielc@php.net> 24 * @copyright 1997-200 5The PHP Group24 * @copyright 1997-2007 The PHP Group 25 25 * @license http://www.php.net/license/3_0.txt PHP License 3.0 26 26 * @version CVS: $Id$ … … 48 48 * @author Sterling Hughes <sterling@php.net> 49 49 * @author Daniel Convissor <danielc@php.net> 50 * @copyright 1997-200 5The PHP Group50 * @copyright 1997-2007 The PHP Group 51 51 * @license http://www.php.net/license/3_0.txt PHP License 3.0 52 * @version Release: @package_version@52 * @version Release: 1.7.13 53 53 * @link http://pear.php.net/package/DB 54 54 * @since Class became stable in Release 1.7.0 … … 124 124 -803 => DB_ERROR_CONSTRAINT, 125 125 -804 => DB_ERROR_VALUE_COUNT_ON_ROW, 126 // -902 => // Covers too many errors, need to use regex on msg 126 127 -904 => DB_ERROR_CONNECT_FAILED, 127 128 -922 => DB_ERROR_NOSUCHDB, … … 276 277 function simpleQuery($query) 277 278 { 278 $ismanip = DB::isManip($query);279 $ismanip = $this->_checkManip($query); 279 280 $this->last_query = $query; 280 281 $query = $this->modifyQuery($query); … … 413 414 function freeResult($result) 414 415 { 415 return @ibase_free_result($result);416 return is_resource($result) ? ibase_free_result($result) : false; 416 417 } 417 418 … … 421 422 function freeQuery($query) 422 423 { 423 @ibase_free_query($query); 424 return true; 424 return is_resource($query) ? ibase_free_query($query) : false; 425 425 } 426 426 … … 522 522 $newquery = $this->modifyQuery($newquery); 523 523 $stmt = @ibase_prepare($this->connection, $newquery); 524 $this->prepare_types[(int)$stmt] = $types; 525 $this->manip_query[(int)$stmt] = DB::isManip($query); 524 525 if ($stmt === false) { 526 $stmt = $this->ibaseRaiseError(); 527 } else { 528 $this->prepare_types[(int)$stmt] = $types; 529 $this->manip_query[(int)$stmt] = DB::isManip($query); 530 } 531 526 532 return $stmt; 527 533 } … … 548 554 $this->last_parameters = $data; 549 555 550 $types = &$this->prepare_types[(int)$stmt];556 $types = $this->prepare_types[(int)$stmt]; 551 557 if (count($types) != count($data)) { 552 $tmp = &$this->raiseError(DB_ERROR_MISMATCH);558 $tmp = $this->raiseError(DB_ERROR_MISMATCH); 553 559 return $tmp; 554 560 } … … 569 575 $fp = @fopen($data[$key], 'rb'); 570 576 if (!$fp) { 571 $tmp = &$this->raiseError(DB_ERROR_ACCESS_VIOLATION);577 $tmp = $this->raiseError(DB_ERROR_ACCESS_VIOLATION); 572 578 return $tmp; 573 579 } … … 582 588 $res = call_user_func_array('ibase_execute', $data); 583 589 if (!$res) { 584 $tmp = &$this->ibaseRaiseError();590 $tmp = $this->ibaseRaiseError(); 585 591 return $tmp; 586 592 } … … 590 596 }*/ 591 597 $this->last_stmt = $stmt; 592 if ($this->manip_query[(int)$stmt]) { 598 if ($this->manip_query[(int)$stmt] || $this->_next_query_manip) { 599 $this->_last_query_manip = true; 600 $this->_next_query_manip = false; 593 601 $tmp = DB_OK; 594 602 } else { 595 $tmp =& new DB_result($this, $res); 603 $this->_last_query_manip = false; 604 $tmp = new DB_result($this, $res); 596 605 } 597 606 return $tmp; … … 699 708 do { 700 709 $this->pushErrorHandling(PEAR_ERROR_RETURN); 701 $result = &$this->query("SELECT GEN_ID(${sqn}, 1) "710 $result = $this->query("SELECT GEN_ID(${sqn}, 1) " 702 711 . 'FROM RDB$GENERATORS ' 703 712 . "WHERE RDB\$GENERATOR_NAME='${sqn}'"); … … 857 866 $errno = $this->errorCode($this->errorNative()); 858 867 } 859 $tmp = &$this->raiseError($errno, null, null, null, @ibase_errmsg());868 $tmp = $this->raiseError($errno, null, null, null, @ibase_errmsg()); 860 869 return $tmp; 861 870 } … … 926 935 '/arithmetic exception, numeric overflow, or string truncation/i' 927 936 => DB_ERROR_INVALID, 937 '/feature is not supported/i' 938 => DB_ERROR_NOT_CAPABLE, 928 939 ); 929 940 } -
trunk/roundcubemail/program/lib/DB/ifx.php
r12 r1377 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$ … … 47 47 * @author Tomas V.V.Cox <cox@idecnet.com> 48 48 * @author Daniel Convissor <danielc@php.net> 49 * @copyright 1997-200 5The PHP Group49 * @copyright 1997-2007 The PHP Group 50 50 * @license http://www.php.net/license/3_0.txt PHP License 3.0 51 * @version Release: @package_version@51 * @version Release: 1.7.13 52 52 * @link http://pear.php.net/package/DB 53 53 */ … … 102 102 '-239' => DB_ERROR_CONSTRAINT, 103 103 '-253' => DB_ERROR_SYNTAX, 104 '-268' => DB_ERROR_CONSTRAINT, 104 105 '-292' => DB_ERROR_CONSTRAINT_NOT_NULL, 105 106 '-310' => DB_ERROR_ALREADY_EXISTS, … … 114 115 '-692' => DB_ERROR_CONSTRAINT, 115 116 '-703' => DB_ERROR_CONSTRAINT_NOT_NULL, 117 '-1202' => DB_ERROR_DIVZERO, 116 118 '-1204' => DB_ERROR_INVALID_DATE, 117 119 '-1205' => DB_ERROR_INVALID_DATE, … … 244 246 function simpleQuery($query) 245 247 { 246 $ismanip = DB::isManip($query);248 $ismanip = $this->_checkManip($query); 247 249 $this->last_query = $query; 248 250 $this->affected = null; 249 if (preg_match('/(SELECT )/i', $query)) { //TESTME: Use !DB::isManip()?251 if (preg_match('/(SELECT|EXECUTE)/i', $query)) { //TESTME: Use !DB::isManip()? 250 252 // the scroll is needed for fetching absolute row numbers 251 253 // in a select query result … … 269 271 // Determine which queries should return data, and which 270 272 // should return an error code only. 271 if (preg_match('/(SELECT )/i', $query)) {273 if (preg_match('/(SELECT|EXECUTE)/i', $query)) { 272 274 return $result; 273 275 } … … 310 312 function affectedRows() 311 313 { 312 if ( DB::isManip($this->last_query)) {314 if ($this->_last_query_manip) { 313 315 return $this->affected; 314 316 } else { … … 421 423 function freeResult($result) 422 424 { 423 return @ifx_free_result($result);425 return is_resource($result) ? ifx_free_result($result) : false; 424 426 } 425 427 -
trunk/roundcubemail/program/lib/DB/msql.php
r12 r1377 22 22 * @package DB 23 23 * @author Daniel Convissor <danielc@php.net> 24 * @copyright 1997-200 5The PHP Group24 * @copyright 1997-2007 The PHP Group 25 25 * @license http://www.php.net/license/3_0.txt PHP License 3.0 26 26 * @version CVS: $Id$ … … 46 46 * @package DB 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.13 51 51 * @link http://pear.php.net/package/DB 52 52 * @since Class not functional until Release 1.7.0 … … 154 154 * ); 155 155 * 156 * $db = &DB::connect($dsn, $options);156 * $db = DB::connect($dsn, $options); 157 157 * if (PEAR::isError($db)) { 158 158 * die($db->getMessage()); … … 191 191 $params); 192 192 } else { 193 ini_set('track_errors', 1);193 @ini_set('track_errors', 1); 194 194 $this->connection = @call_user_func_array($connect_function, 195 195 $params); 196 ini_set('track_errors', $ini);196 @ini_set('track_errors', $ini); 197 197 } 198 198 … … 252 252 // Determine which queries that should return data, and which 253 253 // should return an error code only. 254 if ( DB::isManip($query)) {254 if ($this->_checkManip($query)) { 255 255 $this->_result = $result; 256 256 return DB_OK; … … 351 351 function freeResult($result) 352 352 { 353 return @msql_free_result($result);353 return is_resource($result) ? msql_free_result($result) : false; 354 354 } 355 355 … … 444 444 do { 445 445 $this->pushErrorHandling(PEAR_ERROR_RETURN); 446 $result = &$this->query("SELECT _seq FROM ${seqname}");446 $result = $this->query("SELECT _seq FROM ${seqname}"); 447 447 $this->popErrorHandling(); 448 448 if ($ondemand && DB::isError($result) && … … 532 532 533 533 // }}} 534 // {{{ quoteFloat() 535 536 /** 537 * Formats a float value for use within a query in a locale-independent 538 * manner. 539 * 540 * @param float the float value to be quoted. 541 * @return string the quoted string. 542 * @see DB_common::quoteSmart() 543 * @since Method available since release 1.7.8. 544 */ 545 function quoteFloat($float) { 546 return $this->escapeSimple(str_replace(',', '.', strval(floatval($float)))); 547 } 548 549 // }}} 534 550 // {{{ escapeSimple() 535 551 … … 599 615 { 600 616 static $error_regexps; 617 618 // PHP 5.2+ prepends the function name to $php_errormsg, so we need 619 // this hack to work around it, per bug #9599. 620 $errormsg = preg_replace('/^msql[a-z_]+\(\): /', '', $errormsg); 621 601 622 if (!isset($error_regexps)) { 602 623 $error_regexps = array( -
trunk/roundcubemail/program/lib/DB/mssql.php
r12 r1377 19 19 * @author Sterling Hughes <sterling@php.net> 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$ … … 36 36 * These methods overload the ones declared in DB_common. 37 37 * 38 * DB's mssql driver is only for Microsfoft SQL Server databases. 39 * 40 * If you're connecting to a Sybase database, you MUST specify "sybase" 41 * as the "phptype" in the DSN. 42 * 43 * This class only works correctly if you have compiled PHP using 44 * --with-mssql=[dir_to_FreeTDS]. 45 * 38 46 * @category Database 39 47 * @package DB 40 48 * @author Sterling Hughes <sterling@php.net> 41 49 * @author Daniel Convissor <danielc@php.net> 42 * @copyright 1997-200 5The PHP Group50 * @copyright 1997-2007 The PHP Group 43 51 * @license http://www.php.net/license/3_0.txt PHP License 3.0 44 * @version Release: @package_version@52 * @version Release: 1.7.13 45 53 * @link http://pear.php.net/package/DB 46 54 */ … … 90 98 // XXX Add here error codes ie: 'S100E' => DB_ERROR_SYNTAX 91 99 var $errorcode_map = array( 100 102 => DB_ERROR_SYNTAX, 92 101 110 => DB_ERROR_VALUE_COUNT_ON_ROW, 93 102 155 => DB_ERROR_NOSUCHFIELD, 103 156 => DB_ERROR_SYNTAX, 94 104 170 => DB_ERROR_SYNTAX, 95 105 207 => DB_ERROR_NOSUCHFIELD, 96 106 208 => DB_ERROR_NOSUCHTABLE, 97 107 245 => DB_ERROR_INVALID_NUMBER, 108 319 => DB_ERROR_SYNTAX, 109 321 => DB_ERROR_NOSUCHFIELD, 110 325 => DB_ERROR_SYNTAX, 111 336 => DB_ERROR_SYNTAX, 98 112 515 => DB_ERROR_CONSTRAINT_NOT_NULL, 99 113 547 => DB_ERROR_CONSTRAINT, 114 1018 => DB_ERROR_SYNTAX, 115 1035 => DB_ERROR_SYNTAX, 100 116 1913 => DB_ERROR_ALREADY_EXISTS, 117 2209 => DB_ERROR_SYNTAX, 118 2223 => DB_ERROR_SYNTAX, 119 2248 => DB_ERROR_SYNTAX, 120 2256 => DB_ERROR_SYNTAX, 121 2257 => DB_ERROR_SYNTAX, 101 122 2627 => DB_ERROR_CONSTRAINT, 102 123 2714 => DB_ERROR_ALREADY_EXISTS, 124 3607 => DB_ERROR_DIVZERO, 103 125 3701 => DB_ERROR_NOSUCHTABLE, 126 7630 => DB_ERROR_SYNTAX, 104 127 8134 => DB_ERROR_DIVZERO, 128 9303 => DB_ERROR_SYNTAX, 129 9317 => DB_ERROR_SYNTAX, 130 9318 => DB_ERROR_SYNTAX, 131 9331 => DB_ERROR_SYNTAX, 132 9332 => DB_ERROR_SYNTAX, 133 15253 => DB_ERROR_SYNTAX, 105 134 ); 106 135 … … 245 274 function simpleQuery($query) 246 275 { 247 $ismanip = DB::isManip($query);276 $ismanip = $this->_checkManip($query); 248 277 $this->last_query = $query; 249 278 if (!@mssql_select_db($this->_db, $this->connection)) { … … 317 346 } 318 347 if ($fetchmode & DB_FETCHMODE_ASSOC) { 319 $arr = @mssql_fetch_a rray($result, MSSQL_ASSOC);348 $arr = @mssql_fetch_assoc($result); 320 349 if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) { 321 350 $arr = array_change_key_case($arr, CASE_LOWER); … … 354 383 function freeResult($result) 355 384 { 356 return @mssql_free_result($result);385 return is_resource($result) ? mssql_free_result($result) : false; 357 386 } 358 387 … … 484 513 function affectedRows() 485 514 { 486 if ( DB::isManip($this->last_query)) {515 if ($this->_last_query_manip) { 487 516 $res = @mssql_query('select @@rowcount', $this->connection); 488 517 if (!$res) { … … 538 567 } 539 568 } elseif (!DB::isError($result)) { 540 $result =& $this->query("SELECT @@IDENTITY FROM $seqname"); 569 $result = $this->query("SELECT IDENT_CURRENT('$seqname')"); 570 if (DB::isError($result)) { 571 /* Fallback code for MS SQL Server 7.0, which doesn't have 572 * IDENT_CURRENT. This is *not* safe for concurrent 573 * requests, and really, if you're using it, you're in a 574 * world of hurt. Nevertheless, it's here to ensure BC. See 575 * bug #181 for the gory details.*/ 576 $result = $this->query("SELECT @@IDENTITY FROM $seqname"); 577 } 541 578 $repeat = 0; 542 579 } else { … … 746 783 747 784 for ($i = 0; $i < $count; $i++) { 785 if ($got_string) { 786 $flags = $this->_mssql_field_flags($result, 787 @mssql_field_name($id, $i)); 788 if (DB::isError($flags)) { 789 return $flags; 790 } 791 } else { 792 $flags = ''; 793 } 794 748 795 $res[$i] = array( 749 796 'table' => $got_string ? $case_func($result) : '', … … 751 798 'type' => @mssql_field_type($id, $i), 752 799 'len' => @mssql_field_length($id, $i), 753 // We only support flags for table 754 'flags' => $got_string 755 ? $this->_mssql_field_flags($result, 756 @mssql_field_name($id, $i)) 757 : '', 800 'flags' => $flags, 758 801 ); 759 802 if ($mode & DB_TABLEINFO_ORDER) { … … 806 849 807 850 // get unique and primary keys 808 $res = $this->getAll("EXEC SP_HELPINDEX[$table]", DB_FETCHMODE_ASSOC); 851 $res = $this->getAll("EXEC SP_HELPINDEX $table", DB_FETCHMODE_ASSOC); 852 if (DB::isError($res)) { 853 return $res; 854 } 809 855 810 856 foreach ($res as $val) { … … 829 875 830 876 // get auto_increment, not_null and timestamp 831 $res = $this->getAll("EXEC SP_COLUMNS[$table]", DB_FETCHMODE_ASSOC); 877 $res = $this->getAll("EXEC SP_COLUMNS $table", DB_FETCHMODE_ASSOC); 878 if (DB::isError($res)) { 879 return $res; 880 } 832 881 833 882 foreach ($res as $val) { -
trunk/roundcubemail/program/lib/DB/mysql.php
r12 r1377 19 19 * @author Stig Bakken <ssb@php.net> 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$ … … 40 40 * @author Stig Bakken <ssb@php.net> 41 41 * @author Daniel Convissor <danielc@php.net> 42 * @copyright 1997-200 5The PHP Group42 * @copyright 1997-2007 The PHP Group 43 43 * @license http://www.php.net/license/3_0.txt PHP License 3.0 44 * @version Release: @package_version@44 * @version Release: 1.7.13 45 45 * @link http://pear.php.net/package/DB 46 46 */ … … 112 112 1216 => DB_ERROR_CONSTRAINT, 113 113 1217 => DB_ERROR_CONSTRAINT, 114 1356 => DB_ERROR_DIVZERO, 115 1451 => DB_ERROR_CONSTRAINT, 116 1452 => DB_ERROR_CONSTRAINT, 114 117 ); 115 118 … … 237 240 $params); 238 241 } else { 239 ini_set('track_errors', 1);242 @ini_set('track_errors', 1); 240 243 $this->connection = @call_user_func_array($connect_function, 241 244 $params); 242 ini_set('track_errors', $ini);245 @ini_set('track_errors', $ini); 243 246 } 244 247 … … 298 301 function simpleQuery($query) 299 302 { 300 $ismanip = DB::isManip($query);303 $ismanip = $this->_checkManip($query); 301 304 $this->last_query = $query; 302 305 $query = $this->modifyQuery($query); … … 420 423 function freeResult($result) 421 424 { 422 return @mysql_free_result($result);425 return is_resource($result) ? mysql_free_result($result) : false; 423 426 } 424 427 … … 556 559 function affectedRows() 557 560 { 558 if ( DB::isManip($this->last_query)) {561 if ($this->_last_query_manip) { 559 562 return @mysql_affected_rows($this->connection); 560 563 } else { … … 753 756 /** 754 757 * Quotes a string so it can be safely used as a table or column name 755 * 756 * MySQL can't handle the backtick character (<kbd>`</kbd>) in 757 * table or column names. 758 * (WARNING: using names that require this is a REALLY BAD IDEA) 759 * 760 * WARNING: Older versions of MySQL can't handle the backtick 761 * character (<kbd>`</kbd>) in table or column names. 758 762 * 759 763 * @param string $str identifier name to be quoted … … 766 770 function quoteIdentifier($str) 767 771 { 768 return '`' . $str. '`';772 return '`' . str_replace('`', '``', $str) . '`'; 769 773 } 770 774 … … 853 857 function modifyLimitQuery($query, $from, $count, $params = array()) 854 858 { 855 if (DB::isManip($query) ) {859 if (DB::isManip($query) || $this->_next_query_manip) { 856 860 return $query . " LIMIT $count"; 857 861 } else { … … 929 933 { 930 934 if (is_string($result)) { 935 // Fix for bug #11580. 936 if ($this->_db) { 937 if (!@mysql_select_db($this->_db, $this->connection)) { 938 return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED); 939 } 940 } 941 931 942 /* 932 943 * Probably received a table name. 933 944 * Create a result resource identifier. 934 945 */ 935 $id = @mysql_ list_fields($this->dsn['database'],936 $result,$this->connection);946 $id = @mysql_query("SELECT * FROM $result LIMIT 0", 947 $this->connection); 937 948 $got_string = true; 938 949 } elseif (isset($result->result)) { -
trunk/roundcubemail/program/lib/DB/mysqli.php
r12 r1377 18 18 * @package DB 19 19 * @author Daniel Convissor <danielc@php.net> 20 * @copyright 1997-200 5The PHP Group20 * @copyright 1997-2007 The PHP Group 21 21 * @license http://www.php.net/license/3_0.txt PHP License 3.0 22 22 * @version CVS: $Id$ … … 42 42 * @package DB 43 43 * @author Daniel Convissor <danielc@php.net> 44 * @copyright 1997-200 5The PHP Group44 * @copyright 1997-2007 The PHP Group 45 45 * @license http://www.php.net/license/3_0.txt PHP License 3.0 46 * @version Release: @package_version@46 * @version Release: 1.7.13 47 47 * @link http://pear.php.net/package/DB 48 48 * @since Class functional since Release 1.6.3 … … 115 115 1216 => DB_ERROR_CONSTRAINT, 116 116 1217 => DB_ERROR_CONSTRAINT, 117 1356 => DB_ERROR_DIVZERO, 118 1451 => DB_ERROR_CONSTRAINT, 119 1452 => DB_ERROR_CONSTRAINT, 117 120 ); 118 121 … … 211 214 MYSQLI_TYPE_STRING => 'char', 212 215 MYSQLI_TYPE_GEOMETRY => 'geometry', 216 /* These constants are conditionally compiled in ext/mysqli, so we'll 217 * define them by number rather than constant. */ 218 16 => 'bit', 219 246 => 'decimal', 213 220 ); 214 221 … … 265 272 * ); 266 273 * 267 * $db = &DB::connect($dsn, $options);274 * $db = DB::connect($dsn, $options); 268 275 * if (PEAR::isError($db)) { 269 276 * die($db->getMessage()); … … 288 295 289 296 $ini = ini_get('track_errors'); 290 ini_set('track_errors', 1);297 @ini_set('track_errors', 1); 291 298 $php_errormsg = ''; 292 299 293 if ( $this->getOption('ssl') === true) {300 if (((int) $this->getOption('ssl')) === 1) { 294 301 $init = mysqli_init(); 295 302 mysqli_ssl_set( … … 323 330 } 324 331 325 ini_set('track_errors', $ini);332 @ini_set('track_errors', $ini); 326 333 327 334 if (!$this->connection) { … … 373 380 function simpleQuery($query) 374 381 { 375 $ismanip = DB::isManip($query);382 $ismanip = $this->_checkManip($query); 376 383 $this->last_query = $query; 377 384 $query = $this->modifyQuery($query); … … 491 498 function freeResult($result) 492 499 { 493 return @mysqli_free_result($result);500 return is_resource($result) ? mysqli_free_result($result) : false; 494 501 } 495 502 … … 627 634 function affectedRows() 628 635 { 629 if ( DB::isManip($this->last_query)) {636 if ($this->_last_query_manip) { 630 637 return @mysqli_affected_rows($this->connection); 631 638 } else { … … 824 831 /** 825 832 * Quotes a string so it can be safely used as a table or column name 826 * 827 * MySQL can't handle the backtick character (<kbd>`</kbd>) in 828 * table or column names. 833 * (WARNING: using names that require this is a REALLY BAD IDEA) 834 * 835 * WARNING: Older versions of MySQL can't handle the backtick 836 * character (<kbd>`</kbd>) in table or column names. 829 837 * 830 838 * @param string $str identifier name to be quoted … … 837 845 function quoteIdentifier($str) 838 846 { 839 return '`' . $str. '`';847 return '`' . str_replace('`', '``', $str) . '`'; 840 848 } 841 849 … … 879 887 function modifyLimitQuery($query, $from, $count, $params = array()) 880 888 { 881 if (DB::isManip($query) ) {889 if (DB::isManip($query) || $this->_next_query_manip) { 882 890 return $query . " LIMIT $count"; 883 891 } else { … … 955 963 { 956 964 if (is_string($result)) { 965 // Fix for bug #11580. 966 if ($this->_db) { 967 if (!@mysqli_select_db($this->connection, $this->_db)) { 968 return $this->mysqliRaiseError(DB_ERROR_NODBSELECTED); 969 } 970 } 971 957 972 /* 958 973 * Probably received a table name. … … 1016 1031 ? $this->mysqli_types[$tmp->type] 1017 1032 : 'unknown', 1018 'len' => $tmp->max_length, 1033 // http://bugs.php.net/?id=36579 1034 'len' => $tmp->length, 1019 1035 'flags' => $flags, 1020 1036 ); -
trunk/roundcubemail/program/lib/DB/oci8.php
r12 r1377 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.13 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 = str_replace(':bind'.$i, $this->quoteSmart($data[$key]), $this->last_query); 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 -
trunk/roundcubemail/program/lib/DB/odbc.php
r12 r1377 19 19 * @author Stig Bakken <ssb@php.net> 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$ … … 43 43 * @author Stig Bakken <ssb@php.net> 44 44 * @author Daniel Convissor <danielc@php.net> 45 * @copyright 1997-200 5The PHP Group45 * @copyright 1997-2007 The PHP Group 46 46 * @license http://www.php.net/license/3_0.txt PHP License 3.0 47 * @version Release: @package_version@47 * @version Release: 1.7.13 48 48 * @link http://pear.php.net/package/DB 49 49 */ … … 267 267 // Determine which queries that should return data, and which 268 268 // should return an error code only. 269 if ( DB::isManip($query)) {269 if ($this->_checkManip($query)) { 270 270 $this->affected = $result; // For affectedRows() 271 271 return DB_OK; … … 368 368 function freeResult($result) 369 369 { 370 return @odbc_free_result($result);370 return is_resource($result) ? odbc_free_result($result) : false; 371 371 } 372 372 -
trunk/roundcubemail/program/lib/DB/pgsql.php
r12 r1377 20 20 * @author Stig Bakken <ssb@php.net> 21 21 * @author Daniel Convissor <danielc@php.net> 22 * @copyright 1997-200 5The PHP Group22 * @copyright 1997-2007 The PHP Group 23 23 * @license http://www.php.net/license/3_0.txt PHP License 3.0 24 24 * @version CVS: $Id$ … … 42 42 * @author Stig Bakken <ssb@php.net> 43 43 * @author Daniel Convissor <danielc@php.net> 44 * @copyright 1997-200 5The PHP Group44 * @copyright 1997-2007 The PHP Group 45 45 * @license http://www.php.net/license/3_0.txt PHP License 3.0 46 * @version Release: @package_version@46 * @version Release: 1.7.13 47 47 * @link http://pear.php.net/package/DB 48 48 */ … … 194 194 * ); 195 195 * 196 * $db = &DB::connect($dsn, $options);196 * $db = DB::connect($dsn, $options); 197 197 * if (PEAR::isError($db)) { 198 198 * die($db->getMessage()); … … 278 278 $params); 279 279 } else { 280 ini_set('track_errors', 1);280 @ini_set('track_errors', 1); 281 281 $this->connection = @call_user_func_array($connect_function, 282 282 $params); 283 ini_set('track_errors', $ini);283 @ini_set('track_errors', $ini); 284 284 } 285 285 … … 321 321 function simpleQuery($query) 322 322 { 323 $ismanip = DB::isManip($query);323 $ismanip = $this->_checkManip($query); 324 324 $this->last_query = $query; 325 325 $query = $this->modifyQuery($query); … … 337 337 return $this->pgsqlRaiseError(); 338 338 } 339 // Determine which queries that should return data, and which 340 // should return an error code only. 339 340 /* 341 * Determine whether queries produce affected rows, result or nothing. 342 * 343 * This logic was introduced in version 1.1 of the file by ssb, 344 * though the regex has been modified slightly since then. 345 * 346 * PostgreSQL commands: 347 * ABORT, ALTER, BEGIN, CLOSE, CLUSTER, COMMIT, COPY, 348 * CREATE, DECLARE, DELETE, DROP TABLE, EXPLAIN, FETCH, 349 * GRANT, INSERT, LISTEN, LOAD, LOCK, MOVE, NOTIFY, RESET, 350 * REVOKE, ROLLBACK, SELECT, SELECT INTO, SET, SHOW, 351 * UNLISTEN, UPDATE, VACUUM 352 */ 341 353 if ($ismanip) { 342 354 $this->affected = @pg_affected_rows($result); 343 355 return DB_OK; 344 } elseif (preg_match('/^\s*\(*\s*(SELECT|EXPLAIN|SHOW)\s/si', $query)) { 345 /* PostgreSQL commands: 346 ABORT, ALTER, BEGIN, CLOSE, CLUSTER, COMMIT, COPY, 347 CREATE, DECLARE, DELETE, DROP TABLE, EXPLAIN, FETCH, 348 GRANT, INSERT, LISTEN, LOAD, LOCK, MOVE, NOTIFY, RESET, 349 REVOKE, ROLLBACK, SELECT, SELECT INTO, SET, SHOW, 350 UNLISTEN, UPDATE, VACUUM 351 */ 356 } elseif (preg_match('/^\s*\(*\s*(SELECT|EXPLAIN|FETCH|SHOW)\s/si', 357 $query)) 358 { 352 359 $this->row[(int)$result] = 0; // reset the row counter. 353 360 $numrows = $this->numRows($result); … … 472 479 473 480 // }}} 474 // {{{ quoteSmart() 475 476 /** 477 * Formats input so it can be safely used in a query 478 * 479 * @param mixed $in the data to be formatted 480 * 481 * @return mixed the formatted data. The format depends on the input's 482 * PHP type: 483 * + null = the string <samp>NULL</samp> 484 * + boolean = string <samp>TRUE</samp> or <samp>FALSE</samp> 485 * + integer or double = the unquoted number 486 * + other (including strings and numeric strings) = 487 * the data escaped according to MySQL's settings 488 * then encapsulated between single quotes 481 // {{{ quoteBoolean() 482 483 /** 484 * Formats a boolean value for use within a query in a locale-independent 485 * manner. 486 * 487 * @param boolean the boolean value to be quoted. 488 * @return string the quoted string. 489 * @see DB_common::quoteSmart() 490 * @since Method available since release 1.7.8. 491 */ 492 function quoteBoolean($boolean) { 493 return $boolean ? 'TRUE' : 'FALSE'; 494 } 495 496 // }}} 497 // {{{ escapeSimple() 498 499 /** 500 * Escapes a string according to the current DBMS's standards 501 * 502 * {@internal PostgreSQL treats a backslash as an escape character, 503 * so they are escaped as well. 504 * 505 * @param string $str the string to be escaped 506 * 507 * @return string the escaped string 489 508 * 490 509 * @see DB_common::quoteSmart() 491 510 * @since Method available since Release 1.6.0 492 511 */ 493 function quoteSmart($in) 494 { 495 if (is_int($in) || is_double($in)) { 496 return $in; 497 } elseif (is_bool($in)) { 498 return $in ? 'TRUE' : 'FALSE'; 499 } elseif (is_null($in)) { 500 return 'NULL'; 512 function escapeSimple($str) 513 { 514 if (function_exists('pg_escape_string')) { 515 /* This fixes an undocumented BC break in PHP 5.2.0 which changed 516 * the prototype of pg_escape_string. I'm not thrilled about having 517 * to sniff the PHP version, quite frankly, but it's the only way 518 * to deal with the problem. Revision 1.331.2.13.2.10 on 519 * php-src/ext/pgsql/pgsql.c (PHP_5_2 branch) is to blame, for the 520 * record. */ 521 if (version_compare(PHP_VERSION, '5.2.0', '>=')) { 522 return pg_escape_string($this->connection, $str); 523 } else { 524 return pg_escape_string($str); 525 } 501 526 } else { 502 return "'" . $this->escapeSimple($in) . "'"; 503 } 504 } 505 506 // }}} 507 // {{{ escapeSimple() 508 509 /** 510 * Escapes a string according to the current DBMS's standards 511 * 512 * {@internal PostgreSQL treats a backslash as an escape character, 513 * so they are escaped as well. 514 * 515 * Not using pg_escape_string() yet because it requires PostgreSQL 516 * to be at version 7.2 or greater.}} 517 * 518 * @param string $str the string to be escaped 519 * 520 * @return string the escaped string 521 * 522 * @see DB_common::quoteSmart() 523 * @since Method available since Release 1.6.0 524 */ 525 function escapeSimple($str) 526 { 527 return str_replace("'", "''", str_replace('\\', '\\\\', $str)); 527 return str_replace("'", "''", str_replace('\\', '\\\\', $str)); 528 } 528 529 } 529 530 … … 676 677 do { 677 678 $this->pushErrorHandling(PEAR_ERROR_RETURN); 678 $result = &$this->query("SELECT NEXTVAL('${seqname}')");679 $result = $this->query("SELECT NEXTVAL('${seqname}')"); 679 680 $this->popErrorHandling(); 680 681 if ($ondemand && DB::isError($result) && … … 780 781 { 781 782 $native = $this->errorNative(); 783 if (!$native) { 784 $native = 'Database connection has been lost.'; 785 $errno = DB_ERROR_CONNECT_FAILED; 786 } 782 787 if ($errno === null) { 783 788 $errno = $this->errorCode($native); … … 816 821 if (!isset($error_regexps)) { 817 822 $error_regexps = array( 823 '/column .* (of relation .*)?does not exist/i' 824 => DB_ERROR_NOSUCHFIELD, 818 825 '/(relation|sequence|table).*does not exist|class .* not found/i' 819 826 => DB_ERROR_NOSUCHTABLE, 820 827 '/index .* does not exist/' 821 828 => DB_ERROR_NOT_FOUND, 822 '/column .* does not exist/i'823 => DB_ERROR_NOSUCHFIELD,824 829 '/relation .* already exists/i' 825 830 => DB_ERROR_ALREADY_EXISTS, … … 977 982 $field_name = @pg_fieldname($resource, $num_field); 978 983 984 // Check if there's a schema in $table_name and update things 985 // accordingly. 986 $from = 'pg_attribute f, pg_class tab, pg_type typ'; 987 if (strpos($table_name, '.') !== false) { 988 $from .= ', pg_namespace nsp'; 989 list($schema, $table) = explode('.', $table_name); 990 $tableWhere = "tab.relname = '$table' AND tab.relnamespace = nsp.oid AND nsp.nspname = '$schema'"; 991 } else { 992 $tableWhere = "tab.relname = '$table_name'"; 993 } 994 979 995 $result = @pg_exec($this->connection, "SELECT f.attnotnull, f.atthasdef 980 FROM pg_attribute f, pg_class tab, pg_type typ996 FROM $from 981 997 WHERE tab.relname = typ.typname 982 998 AND typ.typrelid = f.attrelid 983 999 AND f.attname = '$field_name' 984 AND tab.relname = '$table_name'");1000 AND $tableWhere"); 985 1001 if (@pg_numrows($result) > 0) { 986 1002 $row = @pg_fetch_row($result, 0); … … 989 1005 if ($row[1] == 't') { 990 1006 $result = @pg_exec($this->connection, "SELECT a.adsrc 991 FROM pg_attribute f, pg_class tab, pg_type typ, pg_attrdef a1007 FROM $from, pg_attrdef a 992 1008 WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid 993 1009 AND f.attrelid = a.adrelid AND f.attname = '$field_name' 994 AND tab.relname = '$table_name'AND f.attnum = a.adnum");1010 AND $tableWhere AND f.attnum = a.adnum"); 995 1011 $row = @pg_fetch_row($result, 0); 996 1012 $num = preg_replace("/'(.*)'::\w+/", "\\1", $row[0]); … … 1001 1017 } 1002 1018 $result = @pg_exec($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey 1003 FROM pg_attribute f, pg_class tab, pg_type typ, pg_index i1019 FROM $from, pg_index i 1004 1020 WHERE tab.relname = typ.typname 1005 1021 AND typ.typrelid = f.attrelid 1006 1022 AND f.attrelid = i.indrelid 1007 1023 AND f.attname = '$field_name' 1008 AND tab.relname = '$table_name'");1024 AND $tableWhere"); 1009 1025 $count = @pg_numrows($result); 1010 1026 … … 1067 1083 . ' WHERE schemaname NOT IN' 1068 1084 . " ('pg_catalog', 'information_schema', 'pg_toast')"; 1085 case 'schema.views': 1086 return "SELECT schemaname || '.' || viewname from pg_views WHERE schemaname" 1087 . " NOT IN ('information_schema', 'pg_catalog')"; 1069 1088 case 'views': 1070 1089 // Table cols: viewname | viewowner | definition -
trunk/roundcubemail/program/lib/DB/sqlite.php
r12 r1377 20 20 * @author Mika Tuupola <tuupola@appelsiini.net> 21 21 * @author Daniel Convissor <danielc@php.net> 22 * @copyright 1997-200 5The PHP Group22 * @copyright 1997-2007 The PHP Group 23 23 * @license http://www.php.net/license/3_0.txt PHP License 3.0 3.0 24 24 * @version CVS: $Id$ … … 46 46 * @author Mika Tuupola <tuupola@appelsiini.net> 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 3.0 50 * @version Release: @package_version@50 * @version Release: 1.7.13 51 51 * @link http://pear.php.net/package/DB 52 52 */ … … 183 183 * ); 184 184 * 185 * $db = &DB::connect($dsn, $options);185 * $db = DB::connect($dsn, $options); 186 186 * if (PEAR::isError($db)) { 187 187 * die($db->getMessage()); … … 205 205 } 206 206 207 if ($dsn['database']) { 207 if (!$dsn['database']) { 208 return $this->sqliteRaiseError(DB_ERROR_ACCESS_VIOLATION); 209 } 210 211 if ($dsn['database'] !== ':memory:') { 208 212 if (!file_exists($dsn['database'])) { 209 213 if (!touch($dsn['database'])) { … … 230 234 return $this->sqliteRaiseError(DB_ERROR_ACCESS_VIOLATION); 231 235 } 232 } else {233 return $this->sqliteRaiseError(DB_ERROR_ACCESS_VIOLATION);234 236 } 235 237 … … 237 239 238 240 // track_errors must remain on for simpleQuery() 239 ini_set('track_errors', 1);241 @ini_set('track_errors', 1); 240 242 $php_errormsg = ''; 241 243 … … 281 283 function simpleQuery($query) 282 284 { 283 $ismanip = DB::isManip($query);285 $ismanip = $this->_checkManip($query); 284 286 $this->last_query = $query; 285 287 $query = $this->modifyQuery($query); … … 357 359 if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) { 358 360 $arr = array_change_key_case($arr, CASE_LOWER); 361 } 362 363 /* Remove extraneous " characters from the fields in the result. 364 * Fixes bug #11716. */ 365 if (is_array($arr) && count($arr) > 0) { 366 $strippedArr = array(); 367 foreach ($arr as $field => $value) { 368 $strippedArr[trim($field, '"')] = $value; 369 } 370 $arr = $strippedArr; 359 371 } 360 372 } else { … … 728 740 { 729 741 static $error_regexps; 742 743 // PHP 5.2+ prepends the function name to $php_errormsg, so we need 744 // this hack to work around it, per bug #9599. 745 $errormsg = preg_replace('/^sqlite[a-z_]+\(\): /', '', $errormsg); 746 730 747 if (!isset($error_regexps)) { 731 748 $error_regexps = array( -
trunk/roundcubemail/program/lib/DB/storage.php
r12 r1377 17 17 * @package DB 18 18 * @author Stig Bakken <stig@php.net> 19 * @copyright 1997-200 5The PHP Group19 * @copyright 1997-2007 The PHP Group 20 20 * @license http://www.php.net/license/3_0.txt PHP License 3.0 21 21 * @version CVS: $Id$ … … 37 37 * @package DB 38 38 * @author Stig Bakken <stig@php.net> 39 * @copyright 1997-200 5The PHP Group39 * @copyright 1997-2007 The PHP Group 40 40 * @license http://www.php.net/license/3_0.txt PHP License 3.0 41 * @version Release: @package_version@41 * @version Release: 1.7.13 42 42 * @link http://pear.php.net/package/DB 43 43 */ … … 294 294 { 295 295 $classname = strtolower(get_class($this)); 296 $obj = &new $classname($table);296 $obj = new $classname($table); 297 297 foreach ($data as $name => $value) { 298 298 $obj->_properties[$name] = true; … … 446 446 function store() 447 447 { 448 $params = array(); 449 $vars = array(); 448 450 foreach ($this->_changes as $name => $foo) { 449 451 $params[] = &$this->$name; -
trunk/roundcubemail/program/lib/DB/sybase.php
r12 r1377 20 20 * @author Antônio Carlos Venâncio Júnior <floripa@php.net> 21 21 * @author Daniel Convissor <danielc@php.net> 22 * @copyright 1997-200 5The PHP Group22 * @copyright 1997-2007 The PHP Group 23 23 * @license http://www.php.net/license/3_0.txt PHP License 3.0 24 24 * @version CVS: $Id$ … … 45 45 * @author Antônio Carlos Venâncio Júnior <floripa@php.net> 46 46 * @author Daniel Convissor <danielc@php.net> 47 * @copyright 1997-200 5The PHP Group47 * @copyright 1997-2007 The PHP Group 48 48 * @license http://www.php.net/license/3_0.txt PHP License 3.0 49 * @version Release: @package_version@49 * @version Release: 1.7.13 50 50 * @link http://pear.php.net/package/DB 51 51 */ … … 249 249 function simpleQuery($query) 250 250 { 251 $ismanip = DB::isManip($query);251 $ismanip = $this->_checkManip($query); 252 252 $this->last_query = $query; 253 if ( !@sybase_select_db($this->_db, $this->connection)) {253 if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) { 254 254 return $this->sybaseRaiseError(DB_ERROR_NODBSELECTED); 255 255 } … … 371 371 function freeResult($result) 372 372 { 373 return @sybase_free_result($result);373 return is_resource($result) ? sybase_free_result($result) : false; 374 374 } 375 375 … … 436 436 function affectedRows() 437 437 { 438 if ( DB::isManip($this->last_query)) {438 if ($this->_last_query_manip) { 439 439 $result = @sybase_affected_rows($this->connection); 440 440 } else { … … 463 463 { 464 464 $seqname = $this->getSequenceName($seq_name); 465 if ( !@sybase_select_db($this->_db, $this->connection)) {465 if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) { 466 466 return $this->sybaseRaiseError(DB_ERROR_NODBSELECTED); 467 467 } … … 480 480 } 481 481 } elseif (!DB::isError($result)) { 482 $result = &$this->query("SELECT @@IDENTITY FROM $seqname");482 $result = $this->query("SELECT @@IDENTITY FROM $seqname"); 483 483 $repeat = 0; 484 484 } else { … … 530 530 531 531 // }}} 532 // {{{ quoteFloat() 533 534 /** 535 * Formats a float value for use within a query in a locale-independent 536 * manner. 537 * 538 * @param float the float value to be quoted. 539 * @return string the quoted string. 540 * @see DB_common::quoteSmart() 541 * @since Method available since release 1.7.8. 542 */ 543 function quoteFloat($float) { 544 return $this->escapeSimple(str_replace(',', '.', strval(floatval($float)))); 545 } 546 547 // }}} 532 548 // {{{ autoCommit() 533 549 … … 559 575 { 560 576 if ($this->transaction_opcount > 0) { 561 if ( !@sybase_select_db($this->_db, $this->connection)) {577 if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) { 562 578 return $this->sybaseRaiseError(DB_ERROR_NODBSELECTED); 563 579 } … … 582 598 { 583 599 if ($this->transaction_opcount > 0) { 584 if ( !@sybase_select_db($this->_db, $this->connection)) {600 if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) { 585 601 return $this->sybaseRaiseError(DB_ERROR_NODBSELECTED); 586 602 } … … 643 659 { 644 660 static $error_regexps; 661 662 // PHP 5.2+ prepends the function name to $php_errormsg, so we need 663 // this hack to work around it, per bug #9599. 664 $errormsg = preg_replace('/^sybase[a-z_]+\(\): /', '', $errormsg); 665 645 666 if (!isset($error_regexps)) { 646 667 $error_regexps = array( … … 675 696 '/^There are fewer columns in the INSERT statement than values specified/i' 676 697 => DB_ERROR_VALUE_COUNT_ON_ROW, 698 '/Divide by zero/i' 699 => DB_ERROR_DIVZERO, 677 700 ); 678 701 } … … 715 738 * Create a result resource identifier. 716 739 */ 717 if ( !@sybase_select_db($this->_db, $this->connection)) {740 if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) { 718 741 return $this->sybaseRaiseError(DB_ERROR_NODBSELECTED); 719 742 } … … 812 835 $tableName = $table; 813 836 814 // get unique/primary keys 815 $res = $this->getAll("sp_helpindex $table", DB_FETCHMODE_ASSOC); 816 817 if (!isset($res[0]['index_description'])) { 837 /* We're running sp_helpindex directly because it doesn't exist in 838 * older versions of ASE -- unfortunately, we can't just use 839 * DB::isError() because the user may be using callback error 840 * handling. */ 841 $res = @sybase_query("sp_helpindex $table", $this->connection); 842 843 if ($res === false || $res === true) { 844 // Fake a valid response for BC reasons. 818 845 return ''; 819 846 } 820 847 821 foreach ($res as $val) { 848 while (($val = sybase_fetch_assoc($res)) !== false) { 849 if (!isset($val['index_keys'])) { 850 /* No useful information returned. Break and be done with 851 * it, which preserves the pre-1.7.9 behaviour. */ 852 break; 853 } 854 822 855 $keys = explode(', ', trim($val['index_keys'])); 823 856 … … 834 867 } 835 868 } 869 870 sybase_free_result($res); 836 871 837 872 }
Note: See TracChangeset
for help on using the changeset viewer.
