Forums

To display super users in dropdown

webcrea 04 Mar, 2019
Hi,

I try to display the list of the super-users in dropdown.

A read_data with in first group and the user model linked by foreign key user_id.
In group conditions
group.group_id/=:8
Return an array with key/value

But i don't no what, in debug no user appears.

[read_admins] => Array
(
[log] => Array
(
[0] => SELECT `user`.`id` AS `user.id`, `user`.`name` AS `user.name` FROM `xxx_user_usergroup_map` AS `group` LEFT JOIN `xxx_users` AS `user` ON `group`.`user_id` = `user`.`id` WHERE `group`.`group_id` = '8' LIMIT 100;
)

[var] => Array
(
)

)

In phpmyadmin the query shows exactly wath i want
user.id and user.name

what the trouble?
thanks
healyhatman 04 Mar, 2019
Second table should be user_usergroup_map

Where condition should be
group.group_id:8
And set the relationship manually don't rely on the foreign key - because the Joomla table doesn't have a foreign key properly set up. So
group.user_id:user.id
And what have you got in the fields to retrieve?
webcrea 04 Mar, 2019
Hello,

Please read better

...FROM `xxx_user_usergroup_map` AS `group`

group.group_id:8
shows an error 1164
group.group_id:user.8
with
SELECT `user`.`id` AS `user.id`, `user`.`name` AS `user.name`
I got
user.id and user.name

The query works well in phpmyadmin !

Thanks
healyhatman 04 Mar, 2019
You read better buddy. If you read what you originally wrote, you'll see that you stated you were using
group:group_id/=:8
IN GROUP CONDITIONS. Which is the wrong syntax and the wrong place to put it.

I just did what I told you to do and it worked straight away.
 [read_data3] => Array
        (
            [log] => Array
                (
                    [0] => SELECT `user`.`id` AS `user.id`, `user`.`name` AS `user.name` FROM `#_users` AS `user` LEFT JOIN `#_user_usergroup_map` AS `group` ON `group`.`user_id` = `user`.`id` WHERE `group`.`group_id` = '8' LIMIT 100;
                )

            [var] => Array
                (
                    [558] => Kamron Brooks
                    [561] => support@j2store.org
                )

The other thing you should do is put your USER model first and your GROUP model second.
webcrea 04 Mar, 2019
Sorry this isn't in group conditions but in where conditions of the group model

You can see the query in debug
healyhatman 04 Mar, 2019
Put user model first, group model last
webcrea 04 Mar, 2019
ok in CF6 it works...
Thanks
This topic is locked and no more replies can be posted.