domain.field1, domain.field2 -> see bugreport $query = " SELECT $table_domain.* , COUNT( DISTINCT $table_mailbox.username ) AS mailbox_count FROM $table_domain LEFT JOIN $table_mailbox ON $table_domain.domain = $table_mailbox.domain $where GROUP BY $table_domain.domain, $table_domain.description, $table_domain.aliases, $table_domain.mailboxes, $table_domain.maxquota, $table_domain.quota, $table_domain.transport, $table_domain.backupmx, $table_domain.created, $table_domain.modified, $table_domain.active ORDER BY $table_domain.domain "; $result = db_query($query); $domain_properties = array(); while ($row = db_array ($result['result'])) { $domain_properties[$row['domain']] = $row; } # fetch number of aliases # doing this separate is much faster than doing it in one "big" query $query = " SELECT $table_domain.domain, COUNT( DISTINCT $table_alias.address ) AS alias_count FROM $table_domain LEFT JOIN $table_alias ON $table_domain.domain = $table_alias.domain $where GROUP BY $table_domain.domain ORDER BY $table_domain.domain "; $result = db_query($query); while ($row = db_array ($result['result'])) { # add number of aliases to $domain_properties array. mailbox aliases do not count. $domain_properties [$row['domain']] ['alias_count'] = $row['alias_count'] - $domain_properties [$row['domain']] ['mailbox_count']; } $smarty->assign ('domain_properties', $domain_properties); if ($is_superadmin) { $smarty->assign('select_options', select_options($list_admins, array ($fUsername)), false); $smarty->assign('smarty_template', 'adminlistdomain'); } else { $smarty->assign ('select_options', select_options ($list_domains, array ($_GET['domain']))); $smarty->assign ('smarty_template', 'overview-get'); } $smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?>