I’m currently using xPDO 1.0 beta 290 on top of classic MODx 0.9.6.3. (On Apache 2.2 + PHP 5 on Windows FYI). The XML file is the one from this topic:
http://modxcms.com/forums/index.php/topic,25021.0.html plus some extra tables, of course.
I’m trying to create a CRUD interface that ties together these tables: WebUser, WebUserAttributes and WebUserAttributesExtended. Here are the relationships between the three tables (minus the fields):
<object class="modWebUser" table="web_users" extends="modUser">
<composite alias="modWebUserProfile" class="modWebUserProfile" key="id" local="id" foreign="internalKey" cardinality="one" />
<composite alias="modWebUserSetting" class="modWebUserSetting" key="id" local="id" foreign="webuser" cardinality="one" />
<composite alias="modWebGroupMember" class="modWebGroupMember" key="id" local="id" foreign="webuser" cardinality="one" />
<composite alias="modWebUserAttributesExtended" class="modWebUserAttributesExtended" key="id" local="id" foreign="member_id" cardinality="one" />
</object>
<object class="modWebUserProfile" table="web_user_attributes" extends="xPDOSimpleObject">
<aggregate alias="modWebUser" class="modWebUser" key="internalKey" local="internalKey" foreign="id" cardinality="one" />
<aggregate alias="modUserRole" class="modUserRole" key="role" local="role" foreign="id" cardinality="one" />
</object>
<object class="modWebUserAttributesExtended" table="web_user_attributes_extended" extends="xPDOSimpleObject">
<aggregate alias="modWebUser" class="modWebUser" key="member_id" local="member_id" foreign="id" cardinality="one" />
</object>
modWebUserAttributesExtended is basically doing the same job as modWebUserProfile - just a bunch of extra fields. I took the idea from WebLoginPE, rather than add fields to modWebUserProfile . It is a 1-1 link. And yes, I linked Roles to the WebUser table since I wanted that functionality for regular web users.
I understand that the key attribute is now deprecated and the "owner" attribute is now in effect. Is that what’s wrong here?
Can anyone lend a hand regarding what the collection graph + criteria code would be?
--- MEANWHILE, BACK AT THE RANCH... ---
OK here’s what I think is going on. I can get a primary table (e.g. modWebUser) and two related tables (modWebUserProfile, modWebUserAttributesExtended) but as you can see from my first post, only the primary table has values. Both of the other two tables
have only their default values. I may be completely off base here but I thought that xPDO could do joins? The xPDOQuery object seems to support joins (
http://www.xpdo.org/api/xpdo-om/xPDOQuery.html#methodjoin) but there is talk of "See the XPDO_SQL_JOIN constants"; where is this list of constants? The join I’m attempting is actually really simple:
WHERE modWebUser.id = modWebProfile.internalKey AND modWebUser.id = modWebUserAttributesExtended.member_id
And before anyone asks, I’ve also tried using a hard-coded SQL statement in a Criteria. That didn’t even get me this far.
Help me, OpenGeek! You’re my only hope!