Ticket #630: fixed_buggy_sql_request.diff

File fixed_buggy_sql_request.diff, 1.2 kB (added by nuks, 5 months ago)

Adaptation de la requĂȘte pour pgsql

  • 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); 
    6269            $usersCount = -1; 
    6370        } else { 
Download in other formats: Original Format