Hi !
I’m trying to build my own xml schema and using it, but it’s not working.
I want to set a relationship between a date, a place and an event.
One event can happen at several dates, but takes place in one place only.
There can be several events at the same place
There can be several events at the same date - but for now I try it with only one event per date.
So I need a one to many relationship between event and date, and many to one between event and place.
However, when I create a new event/place/date, only event and date are created.
Here is my XML schema :
<?xml version="1.0" encoding="UTF-8"?>
<model package="test" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="">
<object class="test_date" table="test_date" extends="xPDOSimpleObject">
<field key="date" dbtype="datetime" phptype="datetime" null="false"/>
<field key="id_event" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<aggregate alias="event" class="test_event" local="id_event" foreign="id" cardinality="one" owner="local"/>
</object>
<object class="test_place" table="test_place" extends="xPDOSimpleObject">
<field key="place" dbtype="char" precision="100" attributes="" phptype="string" null="1" default="" index=""/>
<aggregate alias="event" class="test_event" local="id" foreign="id_place" cardinality="many" owner="local"/>
</object>
<object class="test_event" table="test_event" extends="xPDOSimpleObject">
<field key="event" dbtype="varchar" precision="100" attributes="" phptype="string" null="" default="" index=""/>
<field key="id_place" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<aggregate alias="place" class="test_place" local="id_place" foreign="id" cardinality="one" owner="foreign"/>
<composite alias="date" class="test_date" local="id" foreign="id_event" cardinality="many" owner="local" />
</object>
</model>
and my code to create the three objects (already defined) :
$new_event->addMany($new_date);
$new_event->addOne($new_place);
$new_event->save();
I can save each one separately, but there is no link between them. When I try to save all three at the same time, Event and Date are created, but no place.
What am I doing wrong ?