Changeset 7028 for trunk/wp-includes/wp-db.php
- Timestamp:
- 02/25/2008 10:00:27 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/wp-db.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/wp-db.php
r6726 r7028 8 8 define('EZSQL_VERSION', 'WP1.25'); 9 9 define('OBJECT', 'OBJECT', true); 10 define('OBJECT_K', 'OBJECT_K', false); 10 11 define('ARRAY_A', 'ARRAY_A', false); 11 12 define('ARRAY_N', 'ARRAY_N', false); … … 397 398 * Return an entire result set from the database 398 399 * @param string $query (can also be null to pull from the cache) 399 * @param string $output ARRAY_A | ARRAY_N | OBJECT 400 * @param string $output ARRAY_A | ARRAY_N | OBJECT_K | OBJECT 400 401 * @return mixed results 401 402 */ … … 408 409 return null; 409 410 410 // Send back array of objects. Each row is an object411 411 if ( $output == OBJECT ) { 412 // Return an integer-keyed array of row objects 412 413 return $this->last_result; 414 } elseif ( $output == OBJECT_K ) { 415 // Return an array of row objects with keys from column 1 416 // (Duplicates are discarded) 417 foreach ( $this->last_result as $row ) { 418 $key = array_shift( get_object_vars( $row ) ); 419 if ( !isset( $new_array[ $key ] ) ) 420 $new_array[ $key ] = $row; 421 } 422 return $new_array; 413 423 } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { 424 // Return an integer-keyed array of... 414 425 if ( $this->last_result ) { 415 426 $i = 0; 416 427 foreach( $this->last_result as $row ) { 417 $new_array[$i] = (array) $row;418 428 if ( $output == ARRAY_N ) { 419 $new_array[$i] = array_values($new_array[$i]); 429 // ...integer-keyed row arrays 430 $new_array[$i] = array_values( get_object_vars( $row ) ); 431 } else { 432 // ...column name-keyed row arrays 433 $new_array[$i] = get_object_vars( $row ); 420 434 } 421 $i++;435 ++$i; 422 436 } 423 437 return $new_array; 424 } else {425 return null;426 438 } 427 439 }
Note: See TracChangeset
for help on using the changeset viewer.