mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 15:08:10 +01:00
Revert [16320] and [16321] for now. Breaks things
git-svn-id: http://svn.automattic.com/wordpress/trunk@16336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8b562f1fb9
commit
00b232ea51
@ -125,13 +125,13 @@ class wpdb {
|
|||||||
var $last_query;
|
var $last_query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MySQL result resource of the last query made
|
* Results of the last query made
|
||||||
*
|
*
|
||||||
* @since 3.1.0
|
* @since 1.0.0
|
||||||
* @access private
|
* @access private
|
||||||
* @var resource|null
|
* @var array|null
|
||||||
*/
|
*/
|
||||||
var $_mysql_last_result;
|
var $last_result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saved info on the table column
|
* Saved info on the table column
|
||||||
@ -1015,8 +1015,7 @@ class wpdb {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function flush() {
|
function flush() {
|
||||||
if ( is_resource( $this->_mysql_last_result ) )
|
$this->last_result = array();
|
||||||
mysql_free_result( $this->_mysql_last_result );
|
|
||||||
$this->col_info = null;
|
$this->col_info = null;
|
||||||
$this->last_query = null;
|
$this->last_query = null;
|
||||||
}
|
}
|
||||||
@ -1086,7 +1085,7 @@ class wpdb {
|
|||||||
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES )
|
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES )
|
||||||
$this->timer_start();
|
$this->timer_start();
|
||||||
|
|
||||||
$this->_mysql_last_result = @mysql_query( $query, $this->dbh );
|
$this->result = @mysql_query( $query, $this->dbh );
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES )
|
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES )
|
||||||
@ -1108,15 +1107,22 @@ class wpdb {
|
|||||||
$return_val = $this->rows_affected;
|
$return_val = $this->rows_affected;
|
||||||
} else {
|
} else {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ( $i < @mysql_num_fields( $this->_mysql_last_result ) ) {
|
while ( $i < @mysql_num_fields( $this->result ) ) {
|
||||||
$this->col_info[$i] = @mysql_fetch_field( $this->_mysql_last_result );
|
$this->col_info[$i] = @mysql_fetch_field( $this->result );
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
$num_rows = 0;
|
||||||
|
while ( $row = @mysql_fetch_object( $this->result ) ) {
|
||||||
|
$this->last_result[$num_rows] = $row;
|
||||||
|
$num_rows++;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mysql_free_result( $this->result );
|
||||||
|
|
||||||
// Log number of rows the query returned
|
// Log number of rows the query returned
|
||||||
// and return number of rows selected
|
// and return number of rows selected
|
||||||
$this->num_rows = @mysql_num_rows( $this->_mysql_last_result );
|
$this->num_rows = $num_rows;
|
||||||
$return_val = $this->num_rows;
|
$return_val = $num_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return_val;
|
return $return_val;
|
||||||
@ -1275,10 +1281,9 @@ class wpdb {
|
|||||||
if ( $query )
|
if ( $query )
|
||||||
$this->query( $query );
|
$this->query( $query );
|
||||||
|
|
||||||
// Extract var from result resource based x,y vals
|
// Extract var out of cached results based x,y vals
|
||||||
if ( $this->num_rows > $y ) {
|
if ( !empty( $this->last_result[$y] ) ) {
|
||||||
@mysql_data_seek( $this->_mysql_last_result, $y );
|
$values = array_values( get_object_vars( $this->last_result[$y] ) );
|
||||||
$values = @mysql_fetch_row( $this->_mysql_last_result );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a value return it else return null
|
// If there is a value return it else return null
|
||||||
@ -1305,17 +1310,15 @@ class wpdb {
|
|||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if ( $this->num_rows <= $y )
|
if ( !isset( $this->last_result[$y] ) )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@mysql_data_seek( $this->_mysql_last_result, $y );
|
|
||||||
|
|
||||||
if ( $output == OBJECT ) {
|
if ( $output == OBJECT ) {
|
||||||
return @mysql_fetch_object( $this->_mysql_last_result );
|
return $this->last_result[$y] ? $this->last_result[$y] : null;
|
||||||
} elseif ( $output == ARRAY_A ) {
|
} elseif ( $output == ARRAY_A ) {
|
||||||
return @mysql_fetch_assoc( $this->_mysql_last_result );
|
return $this->last_result[$y] ? get_object_vars( $this->last_result[$y] ) : null;
|
||||||
} elseif ( $output == ARRAY_N ) {
|
} elseif ( $output == ARRAY_N ) {
|
||||||
return @mysql_fetch_row( $this->_mysql_last_result );
|
return $this->last_result[$y] ? array_values( get_object_vars( $this->last_result[$y] ) ) : null;
|
||||||
} else {
|
} else {
|
||||||
$this->print_error(/*WP_I18N_DB_GETROW_ERROR*/" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"/*/WP_I18N_DB_GETROW_ERROR*/);
|
$this->print_error(/*WP_I18N_DB_GETROW_ERROR*/" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"/*/WP_I18N_DB_GETROW_ERROR*/);
|
||||||
}
|
}
|
||||||
@ -1340,13 +1343,8 @@ class wpdb {
|
|||||||
|
|
||||||
$new_array = array();
|
$new_array = array();
|
||||||
// Extract the column values
|
// Extract the column values
|
||||||
@mysql_data_seek( $this->_mysql_last_result, 0 );
|
for ( $i = 0, $j = count( $this->last_result ); $i < $j; $i++ ) {
|
||||||
for ( $i = 0, $j = $this->num_rows; $i < $j; $i++ ) {
|
$new_array[$i] = $this->get_var( null, $x, $i );
|
||||||
$values = @mysql_fetch_row( $this->_mysql_last_result );
|
|
||||||
if ( isset( $values[$x] ) && $values[$x] !== '' )
|
|
||||||
$new_array[$i] = $values[$x];
|
|
||||||
else
|
|
||||||
$new_array[$i] = null;
|
|
||||||
}
|
}
|
||||||
return $new_array;
|
return $new_array;
|
||||||
}
|
}
|
||||||
@ -1373,32 +1371,30 @@ class wpdb {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
$new_array = array();
|
$new_array = array();
|
||||||
@mysql_data_seek( $this->_mysql_last_result, 0 );
|
|
||||||
if ( $output == OBJECT ) {
|
if ( $output == OBJECT ) {
|
||||||
// Return an integer-keyed array of row objects
|
// Return an integer-keyed array of row objects
|
||||||
for ( $i = 0, $j = $this->num_rows; $i < $j; $i++ ) {
|
return $this->last_result;
|
||||||
$new_array[] = @mysql_fetch_object( $this->_mysql_last_result );
|
|
||||||
}
|
|
||||||
return $new_array;
|
|
||||||
} elseif ( $output == OBJECT_K ) {
|
} elseif ( $output == OBJECT_K ) {
|
||||||
// Return an array of row objects with keys from column 1
|
// Return an array of row objects with keys from column 1
|
||||||
// (Duplicates are discarded)
|
// (Duplicates are discarded)
|
||||||
while ( $row = @mysql_fetch_object( $this->_mysql_last_result ) ) {
|
foreach ( $this->last_result as $row ) {
|
||||||
$key = array_shift( $var_by_ref = get_object_vars( $row ) );
|
$key = array_shift( $var_by_ref = get_object_vars( $row ) );
|
||||||
if ( ! isset( $new_array[ $key ] ) )
|
if ( ! isset( $new_array[ $key ] ) )
|
||||||
$new_array[ $key ] = $row;
|
$new_array[ $key ] = $row;
|
||||||
}
|
}
|
||||||
return $new_array;
|
return $new_array;
|
||||||
} elseif ( $output == ARRAY_A ) {
|
} elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
|
||||||
// Return an integer-keyed array of column name-keyed row arrays
|
// Return an integer-keyed array of...
|
||||||
for ( $i = 0, $j = $this->num_rows; $i < $j; $i++ ) {
|
if ( $this->last_result ) {
|
||||||
$new_array[] = @mysql_fetch_assoc( $this->_mysql_last_result );
|
foreach( (array) $this->last_result as $row ) {
|
||||||
}
|
if ( $output == ARRAY_N ) {
|
||||||
return $new_array;
|
// ...integer-keyed row arrays
|
||||||
} elseif ( $output == ARRAY_N ) {
|
$new_array[] = array_values( get_object_vars( $row ) );
|
||||||
// Return an integer-keyed array of integer-keyed row arrays
|
} else {
|
||||||
for ( $i = 0, $j = $this->num_rows; $i < $j; $i++ ) {
|
// ...column name-keyed row arrays
|
||||||
$new_array[] = @mysql_fetch_row( $this->_mysql_last_result );
|
$new_array[] = get_object_vars( $row );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $new_array;
|
return $new_array;
|
||||||
}
|
}
|
||||||
@ -1563,20 +1559,6 @@ class wpdb {
|
|||||||
function db_version() {
|
function db_version() {
|
||||||
return preg_replace( '/[^0-9.].*/', '', mysql_get_server_info( $this->dbh ) );
|
return preg_replace( '/[^0-9.].*/', '', mysql_get_server_info( $this->dbh ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic getter used for the deprecated last_result property.
|
|
||||||
*
|
|
||||||
* @since 3.1.0
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function __get( $name ) {
|
|
||||||
if ( 'last_result' == $name ) {
|
|
||||||
_deprecated_argument( 'wpdb', '3.1', __( 'The last_result property is deprecated. Use $wpdb->get_result().' ) );
|
|
||||||
return $this->get_results();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user