<?xml version="1.0" encoding="UTF-8"?> <model package="providerstorefinder" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" phpdoc-package="providerstorefinder" phpdoc-subpackage="model"> <object class="sfStore" table="sfinder_stores" extends="xPDOSimpleObject"> <field key="name" dbtype="varchar" precision="100" phptype="string" null="false" default="" index="index" /> <field key="published" dbtype="bool" null="false" default="true" /> <field key="active" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /> <composite alias="Phone" class="pHones" local="id" foreign="phone" cardinality="many" owner="local" /> <composite alias="StartEndDate" class="StartEndDates" local="id" foreign="startenddate" cardinality="many" owner="local" /> </object> <object class="provStore" table="provider_stores" extends="xPDOSimpleObject"> <field key="name" dbtype="varchar" precision="100" phptype="string" null="false" default="" index="index" /> <field key="published" dbtype="bool" null="false" default="true" /> <field key="active" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /> <composite alias="Phone" class="pHones" local="id" foreign="phone" cardinality="many" owner="local" /> <composite alias="StartEndDate" class="StartEndDates" local="id" foreign="startenddate" cardinality="many" owner="local" /> </object> <object class="pHone" table="phone" extends="xPDOSimpleObject"> <field key="phone" dbtype="varchar" precision="20" phptype="string" null="false" default="" /> <field key="active" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /></object> <object class="StartEndDate" table="startenddate" extends="xPDOSimpleObject"> <field key="StartDate" dbtype="date" precision="14" phptype="string" null="false" default="" /> <field key="EndDate" dbtype="date" precision="14" phptype="string" null="false" default="" /> <field key="active" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" index="index" /> </object> </model>
For 1 & 3, what do you mean by "divide tables"? I am not understanding the question.
1 - The relationship to divide tables
2 - The date field
3 - Is it advisable to divide tables?
4- By extending the class xPDOSimpleObject, should we relate to the user tables?
<?php $mdyStartDate = $StartEndDateObj->get('StartDate', '%m-%d-%Y'); ?>
<object class="sfStore" table="sfinder_stores" extends="xPDOSimpleObject">
<field key="name" dbtype="varchar" precision="100" phptype="string" null="false" default="" index="index" />
<field key="active" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
<composite alias="Sfinder_Stores_Messages" class="messages" local="id" foreign="modx_user_messages" cardinality="many" owner="local" />
</object>
<field key="user" dbtype="int" precision="10" phptype="integer" attributes="unsigned" null="false" default="0" index="index" /> <aggregate alias="User" class="modUser" local="user" foreign="id" cardinality="one" owner="foreign" />
<field key="active" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />Is it right or I still lost?
<composite alias="User" class="modUser" local="active" foreign="id" cardinality="many" owner="foreign" />
I think you’re still lost a bit. You can’t have a foreign key of user that is an integer of precision 1; the modUser.id column is an integer with precision 10 and your foreign key field must match that.
I need to:
Each registered user can record many businesses. and these are deleted when you delete the User
<field key="active" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />Is it right or I still lost?
<composite alias="User" class="modUser" local="active" foreign="id" cardinality="many" owner="foreign" />
<object class="modAccessPolicy" table="access_policies" extends="xPDOSimpleObject">
<field key="name" dbtype="varchar" precision="255" phptype="string" null="false" index="unique" />
<field key="description" dbtype="mediumtext" phptype="string" />
<field key="parent" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" index="index" />
<field key="class" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
<field key="data" dbtype="text" phptype="json" default="{}" />
<aggregate alias="Parent" class="modAccessPolicy" local="parent" foreign="id" owner="foreign" cardinality="one" />
<aggregate alias="Children" class="modAccessPolicy" local="id" foreign="parent" owner="local" cardinality="many" />
</object>
For Children of the current record, the foreign key is the parent field; so if the foreign ’parent’ equals the local ’id’, this identifies Children in this self-referential relationship. For the current record’s Parent, it’s just the opposite: if the foreign ’id’ equals the local ’parent’, well, then that is the Parent object. Owner means, which side of the relationship owns the key, the foreign entity or the local one.
What is the difference between local="parent" and local="id" in this instance?
owner="foreign", owner="local" Of what? What that meant?