Changeset 18609 for tmp/version-2_5-test/data/module/DB/mssql.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/mssql.php
r15532 r18609 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.14RC1 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) {
Note: See TracChangeset
for help on using the changeset viewer.