You are here

function views_handler_sort_user_ip_count::query in User Stats 7

Same name and namespace in other branches
  1. 6 views/views_handler_sort_user_ip_count.inc \views_handler_sort_user_ip_count::query()

Called to add the sort to a query.

Overrides views_handler_sort::query

File

views/views_handler_sort_user_ip_count.inc, line 12
User Stats IP address count by user.

Class

views_handler_sort_user_ip_count
IP addresses by user count handler.

Code

function query() {
  $this
    ->ensure_my_table();

  // We need another subquery here to extract DISTINCT values
  $sql = "SELECT COUNT(usi.ip_address)\n      FROM (SELECT DISTINCT(uid), ip_address FROM {user_stats_ips}) usi\n      WHERE usi.uid = " . check_plain($this->table_alias) . ".uid";
  $this->field_alias = $this->query
    ->add_orderby(NULL, "(" . $sql . ")", $this->options['order'], $this->table_alias . '_' . $this->field);
}