Changeset 16974
- Timestamp:
- 12/15/2010 11:56:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/user.php
r16956 r16974 352 352 var $total_users = 0; 353 353 354 // SQL pieces 354 // SQL clauses 355 var $query_fields; 355 356 var $query_from; 356 357 var $query_where; … … 407 408 $qv = &$this->query_vars; 408 409 409 $this->query_from = " FROM $wpdb->users"; 410 $this->query_where = " WHERE 1=1"; 410 if ( is_array( $qv['fields'] ) ) { 411 $qv['fields'] = array_unique( $qv['fields'] ); 412 413 $this->query_fields = array(); 414 foreach ( $qv['fields'] as $field ) 415 $this->query_fields[] = $wpdb->users . '.' . esc_sql( $field ); 416 $this->query_fields = implode( ',', $this->query_fields ); 417 } else { 418 $this->query_fields = "$wpdb->users.ID"; 419 } 420 421 $this->query_from = "FROM $wpdb->users"; 422 $this->query_where = "WHERE 1=1"; 411 423 412 424 // sorting … … 438 450 else 439 451 $order = 'DESC'; 440 $this->query_orderby = " 452 $this->query_orderby = "ORDER BY $orderby $order"; 441 453 442 454 // limit 443 455 if ( $qv['number'] ) { 444 456 if ( $qv['offset'] ) 445 $this->query_limit = $wpdb->prepare(" 457 $this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']); 446 458 else 447 $this->query_limit = $wpdb->prepare(" 459 $this->query_limit = $wpdb->prepare("LIMIT %d", $qv['number']); 448 460 } 449 461 … … 511 523 global $wpdb; 512 524 513 $this->results = $wpdb->get_col("SELECT $wpdb->users.ID" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit); 525 if ( is_array( $this->query_vars['fields'] ) ) { 526 $this->results = $wpdb->get_results("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); 527 } else { 528 $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); 529 } 514 530 515 531 if ( !$this->results ) … … 517 533 518 534 if ( $this->query_vars['count_total'] ) 519 $this->total_users = $wpdb->get_var("SELECT COUNT($wpdb->users.ID) " . $this->query_from . $this->query_where);535 $this->total_users = $wpdb->get_var("SELECT COUNT($wpdb->users.ID) $this->query_from $this->query_where $this->query_orderby $this->query_limit"); 520 536 521 537 if ( 'all' == $this->query_vars['fields'] ) { … … 968 984 extract( $r, EXTR_SKIP ); 969 985 970 $users = get_users( wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order' ) ) ); 986 $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order' ) ); 987 $query_args['fields'] = array( 'ID', $show ); 988 989 $users = get_users( $query_args ); 971 990 972 991 $output = '';
Note: See TracChangeset
for help on using the changeset viewer.