Hi
I am using Revo 2.2.2pl and the Login addon v 1.8.0.
I want to do a look up joining both 'modx_users' and 'modx_user_attributes' tables.
However 'modx_users' has a column 'id' (Primary key) and 'modx_user_attributes' has two columns 'id' (Primary key) and 'internalKey' all of which *seem* to be the same. IE a key that relates between the two tables.
So user 'John' id 1 has a record in the user profile table also with an id of 1 AND an internalKey of 1 as well.
So to do the join the two tables correctly with a query should I join on
'modx_users' .'id' = 'modx_user_attributes' .'id'
OR
'modx_users' .'id' = 'modx_user_attributes' .'internalKey'
I have had a look around and check some of the Login code but could not find what differentiates 'modx_user_attributes' .'id' / 'modx_user_attributes' .'internalKey'
Also on a side note if these rows are in a one to one relationship (which I guess they must be) why separate them into two tables? I am sure there is a valid reason?
Thanks in advace.
[ed. note: megasteve4 last edited this post 14 years ago.]
-
☆ A M B ☆
- 24,524 Posts
No, the "id" of the modx_user_attributes table is the ID of that entry in the table. It is usually the same as the internalKey, but really has no relationship to the modx_users table. Always use the internalKey as the relationship between the modx_users table and any other table.
The table structure is an artifact of the origins of MODx, going back as far as Etomite. As to what the advantage may have been perceived to be, I have no idea. xPDO and modUser helps make dealing with it much easier.
Ok thanks Susan - all makes sense now!