Ticket #630: fixed_2buggy_sql_requests.diff

File fixed_2buggy_sql_requests.diff, 1.4 kB (added by nuks, 7 months ago)

Un autre bug corrigé juste à coté

  • lib/jelix-admin-modules/jacl2_admin/controllers/users.classic.php

    old new  
    5555 
    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'; 
    6058            $cnx = jDb::getConnection($p); 
     59            if($cnx->dbms != 'pgsql') { 
     60            // with MYSQL 4.0.12, you must use an alias with the count to use it with HAVING 
     61                $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM jacl2_user_group  
     62                        GROUP BY login HAVING nbgrp < 2 ORDER BY login'; 
     63            } else { 
     64            // But PgSQL doesn't support the HAVING structure with an alias. 
     65                    $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM jacl2_user_group  
     66                            GROUP BY login HAVING count(id_aclgrp) < 2 ORDER BY login'; 
     67            } 
    6168            $rs = $cnx->query($sql); 
    62             $usersCount = -1
     69            $usersCount = $rs->rowCount()
    6370        } else { 
    6471            //in a specific group 
    6572            $dao = jDao::get('jelix~jacl2usergroup',$p); 
Download in other formats: Original Format