Changeset 21472
- Timestamp:
- 08/08/2012 06:24:59 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/wp-db.php
r21471 r21472 135 135 * 136 136 * @since 1.2.0 137 * @access pr ivate137 * @access protected 138 138 * @var array 139 139 */ 140 var$col_info;140 protected $col_info; 141 141 142 142 /** … … 514 514 function __destruct() { 515 515 return true; 516 } 517 518 /** 519 * PHP5 style magic getter, used to lazy-load expensive data. 520 * 521 * @since 3.5.0 522 * 523 * @param string $var The private member to get, and optionally process 524 * @return mixed The private member 525 */ 526 function __get( $var ) { 527 if ( 'col_info' == $var ) 528 $this->load_col_info(); 529 530 return $this->$var; 516 531 } 517 532 … … 903 918 $query = str_replace( "'%s'", '%s', $query ); // in case someone mistakenly already singlequoted it 904 919 $query = str_replace( '"%s"', '%s', $query ); // doublequote unquoting 905 $query = str_replace( '%f' , '%F', $query ); // Force floats to be locale unaware 920 $query = str_replace( '%f' , '%F', $query ); // Force floats to be locale unaware 906 921 $query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s 907 922 array_walk( $args, array( &$this, 'escape_by_ref' ) ); … … 1026 1041 $this->col_info = null; 1027 1042 $this->last_query = null; 1043 @mysql_free_result( $this->result ); 1028 1044 } 1029 1045 … … 1118 1134 $return_val = $this->rows_affected; 1119 1135 } else { 1120 $i = 0;1121 while ( $i < @mysql_num_fields( $this->result ) ) {1122 $this->col_info[$i] = @mysql_fetch_field( $this->result );1123 $i++;1124 }1125 1136 $num_rows = 0; 1126 1137 while ( $row = @mysql_fetch_object( $this->result ) ) { … … 1128 1139 $num_rows++; 1129 1140 } 1130 1131 @mysql_free_result( $this->result );1132 1141 1133 1142 // Log number of rows the query returned … … 1459 1468 1460 1469 /** 1470 * Load the column metadata from the last query. 1471 * 1472 * @since 3.5.0 1473 * 1474 * @access protected 1475 */ 1476 protected function load_col_info() { 1477 if ( $this->col_info ) 1478 return; 1479 1480 for ( $i = 0; $i < @mysql_num_fields( $this->result ); $i++ ) { 1481 $this->col_info[ $i ] = @mysql_fetch_field( $this->result, $i ); 1482 } 1483 } 1484 1485 /** 1461 1486 * Retrieve column metadata from the last query. 1462 1487 * … … 1468 1493 */ 1469 1494 function get_col_info( $info_type = 'name', $col_offset = -1 ) { 1495 $this->load_col_info(); 1496 1470 1497 if ( $this->col_info ) { 1471 1498 if ( $col_offset == -1 ) {
Note: See TracChangeset
for help on using the changeset viewer.