list-domain.php:

- add explicit field list in SELECT to avoid PgSQL problems with custom columns

Reported by ksb (ksb4ever@SF),
https://sourceforge.net/tracker/?func=detail&aid=2859165&group_id=191583&atid=937964


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/branches/postfixadmin-2.3@1029 a1433add-5e2c-0410-b055-b7f2511e0802
postfixadmin-2.3
Christian Boltz 13 years ago
parent eb8fafbc89
commit 86aabcfa06

@ -15,6 +15,7 @@ Changes after 2.3.3 release (postfixadmin-2.3 branch)
- generate more secure random passwords
- squirrelmail plugin: fix typo in variable name
- list-domain: fix SELECT query to work with PgSQL even when using custom fields
Version 2.3.3 - 2011/03/14 - SVN r1010 (postfixadmin-2.3 branch)
---------------------------------------------------------------

@ -63,15 +63,21 @@ if ($list_all_domains == 1) {
}
# fetch domain data and number of mailboxes
# (PgSQL requires the extensive GROUP BY statement, https://sourceforge.net/forum/message.php?msg_id=7386240)
# PgSQL requires the extensive GROUP BY statement (https://sourceforge.net/forum/message.php?msg_id=7386240)
# and also in the field list (https://sourceforge.net/tracker/?func=detail&aid=2859165&group_id=191583&atid=937964)
# Note: future versions should auto-generate the field list based on $struct in DomainHandler (use all fields from the domain table)
$table_domain_fieldlist = "
$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
";
$query = "
SELECT $table_domain.* , COUNT( DISTINCT $table_mailbox.username ) AS mailbox_count
SELECT $table_domain_fieldlist , 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
GROUP BY $table_domain_fieldlist
ORDER BY $table_domain.domain
";
$result = db_query($query);

Loading…
Cancel
Save