Correction jointure

This commit is contained in:
Alan Garcia 2012-10-22 08:58:53 +00:00
parent da6fc77d67
commit 7bafc9b097
1 changed files with 15 additions and 10 deletions

View File

@ -180,16 +180,21 @@ class m_mail {
global $db,$err,$cuid; global $db,$err,$cuid;
$err->log("mail","enum_domains"); $err->log("mail","enum_domains");
if ($uid == -1) { $uid = $cuid; } if ($uid == -1) { $uid = $cuid; }
$db->query("SELECT domaines.id,domaines.domaine, IFNULL(mail, 0) as nb_mail $db->query("
FROM domaines SELECT
LEFT JOIN d.id,
(SELECT address.id, COUNT(*) AS mail d.domaine,
FROM address IFNULL( COUNT(a.id), 0) as nb_mail
WHERE type='' FROM
GROUP BY address.domain_id) subreq domaines d LEFT JOIN address a ON (d.id=a.domain_id AND a.type='')
USING (id) WHERE
WHERE COMPTE={$uid} d.compte = $uid
order by domaines.domaine"); GROUP BY
d.id
ORDER BY
d.domaine
;
");
$this->enum_domains=array(); $this->enum_domains=array();
while($db->next_record()){ while($db->next_record()){
$this->enum_domains[]=$db->Record; $this->enum_domains[]=$db->Record;