developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 12 years ago

Closed 12 years ago

#882 closed bug (fixed)

no table prefix manage with usersCtrl of jacl2db_admin subpackage

Reported by: foxmask Owned by:
Priority: normal Milestone: Jelix 1.1.2
Component: module:jacl2db_admin Version: 1.1.1
Severity: major Keywords:
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version:

Description

Actually we cant query jacl2_user_group as the table_prefix is not used.

in userCtrl controller :

line 59 to 67 we have :

            //only those who have no groups
            if($cnx->dbms != 'pgsql') { 
                // with MYSQL 4.0.12, you must use an alias with the count to use it with HAVING 
                $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM jacl2_user_group
                        GROUP BY login HAVING nbgrp < 2 ORDER BY login';
            } else { 
                // But PgSQL doesn't support the HAVING structure with an alias. 
                $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM jacl2_user_group
                        GROUP BY login HAVING count(id_aclgrp) < 2 ORDER BY login';
            }

we should have :

            $prefix = array_key_exists('table_prefix',$cnx->profile) ? $cnx->profile['table_prefix'] : '';
            //only those who have no groups
            if($cnx->dbms != 'pgsql') { 
                // with MYSQL 4.0.12, you must use an alias with the count to use it with HAVING 
                $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM '.$prefix .'jacl2_user_group
                        GROUP BY login HAVING nbgrp < 2 ORDER BY login';
            } else { 
                // But PgSQL doesn't support the HAVING structure with an alias. 
                $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM '.$prefix .'jacl2_user_group
                        GROUP BY login HAVING count(id_aclgrp) < 2 ORDER BY login';
            }

i'm sorry ; i cant make a patch actually.

Change History (3)

comment:1 Changed 12 years ago by laurentj

  • Milestone set to Jelix 1.1.2
  • Severity changed from blocker to major

no, you should use the prefixTable method of the jDbConnection object, not trying to get the prefix by yourself.

comment:2 Changed 12 years ago by foxmask

will it be better like that ?

            if($cnx->dbms != 'pgsql') { 
                // with MYSQL 4.0.12, you must use an alias with the count to use it with HAVING 
                $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM '.$cnx->prefixTable('')  .'jacl2_user_group
                        GROUP BY login HAVING nbgrp < 2 ORDER BY login';
            } else { 
                // But PgSQL doesn't support the HAVING structure with an alias. 
                $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM '.$cnx->prefixTable('') .'jacl2_user_group
                        GROUP BY login HAVING count(id_aclgrp) < 2 ORDER BY login';
            }

?

if so i can submit a patch ; otherwise what do i miss ?

comment:3 Changed 12 years ago by laurentj

  • Resolution set to fixed
  • Status changed from new to closed

Did you read the documentation of prefixTable() ?

$cnx->prefixTable('jacl2_user_group')

;-)

Fixed in the trunk+1.1.x. r1352. Thanks for your report.

Note: See TracTickets for help on using tickets.