mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Database: Move the if statement outside of the loop.
In the foreach loop of last results, move the if statement outside of the loop. There is no need to check every element in the array for the output type. Do this once outside of the loop. For large database queries with lots of rows returned, this should improve PHP performance. Props spacedmonkey, Cybr, johnbillion, costdev, joemcgill. Fixes #56541. git-svn-id: https://develop.svn.wordpress.org/trunk@56066 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3137,11 +3137,13 @@ class wpdb {
|
||||
} elseif ( ARRAY_A === $output || ARRAY_N === $output ) {
|
||||
// Return an integer-keyed array of...
|
||||
if ( $this->last_result ) {
|
||||
foreach ( (array) $this->last_result as $row ) {
|
||||
if ( ARRAY_N === $output ) {
|
||||
if ( ARRAY_N === $output ) {
|
||||
foreach ( (array) $this->last_result as $row ) {
|
||||
// ...integer-keyed row arrays.
|
||||
$new_array[] = array_values( get_object_vars( $row ) );
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
foreach ( (array) $this->last_result as $row ) {
|
||||
// ...column name-keyed row arrays.
|
||||
$new_array[] = get_object_vars( $row );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user