-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
Data model :
admin_userstable (extendsuserstable)zonestableadmin_users_zonestable to storeadmin_user_id,zone_id
Problem encountered: when listing admin_users (using find() method in UserDao.php) with their zones and ordering on them, my lines are duplicated. But the "count" method still returns the correct number.
Here is the SQL request generated by TDBM:
SELECT DISTINCT
`users`.`id` AS `users____id`, `users`.`email` AS `users____email`,
`zones`.`id` AS `zones____id`, `zones`.`label` AS `zones____label`
FROM `admin_users`
LEFT JOIN `users` ON ( `admin_users`.`id` = `users`.`id`)
LEFT JOIN `admin_users_zones` ON ( `admin_users_zones`.`admin_user_id` = `admin_users`.`id`)
LEFT JOIN `zones` ON ( `admin_users_zones`.`zone_id` = `zones`.`id`)
LEFT JOIN `admin_users_poles` ON ( `admin_users`.`pole_id` = `admin_users_poles`.`id`)
LEFT JOIN `admin_users_roles` ON ( `admin_users`.`role_id` = `admin_users_roles`.`id`)
LEFT JOIN `user_status` ON ( `users`.`status_id` = `user_status`.`id`)
WHERE ( ( ( `users`.`lastname` LIKE '%%')
OR ( `users`.`firstname` LIKE '%%')))
AND ( ( `users`.`email` LIKE '%admin@mail.com%'))
ORDER BY `zones`.`label` ASC LIMIT 10
Data model creation:
create users (id, email)
create roles (id, label)
create users_roles (id_user, id_role)
insert into roles (1, 'A'), (2, 'b')
insert into users (1, 'admin')
insert into users_roles (1, 1), (1, 2)
Method called: ->find('', [], 'roles.label ASC')
Metadata
Metadata
Assignees
Labels
No labels
