Changeset 1002

Show
Ignore:
Timestamp:
06/25/08 21:32:35 (2 months ago)
Author:
laurentj
Message:

ticket #630: bad sql query in jacl2 admin module when using postgresql. p=nuks

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix-admin-modules/jacl2_admin/controllers/users.classic.php

    r873 r1002  
    5656        } elseif($grpid == -1) { 
    5757            //only those who have no groups 
    58             $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM jacl2_user_group  
    59                     GROUP BY login HAVING nbgrp < 2 ORDER BY login'; 
     58            if($cnx->dbms != 'pgsql') {  
     59                // with MYSQL 4.0.12, you must use an alias with the count to use it with HAVING  
     60                $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM jacl2_user_group 
     61                        GROUP BY login HAVING nbgrp < 2 ORDER BY login'; 
     62            } else {  
     63                // But PgSQL doesn't support the HAVING structure with an alias.  
     64                $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM jacl2_user_group 
     65                        GROUP BY login HAVING count(id_aclgrp) < 2 ORDER BY login'; 
     66            } 
     67 
    6068            $cnx = jDb::getConnection($p); 
    6169            $rs = $cnx->query($sql); 
    62             $usersCount = -1
     70            $usersCount = $rs->rowCount()
    6371        } else { 
    6472            //in a specific group 
Download in other formats: Unified Diff Zip Archive