hi,
I’m trying to model some address information for a web site user. i’ve created a linked list of countries->regions->cities, and want to be able to store the city and region of the web user by referencing a foreign key from the regions table.
how would I do this? I’m not quite clear on the composites array.
below is the map for the region object:
$xpdo_meta_map['Region']['table']= 'region';
$xpdo_meta_map['Region']['fields']= array (
'name' => '', // region name
'parent' => 0 // id of this region's parent
);
$xpdo_meta_map['Region']['fieldMeta']= array (
'name' => array('dbtype' => 'VARCHAR', 'precision' => '200', 'phptype' => 'string', 'null' => false, ),
'parent' => array('dbtype' => 'UNSIGNED SMALLINT', 'phptype' => 'integer', 'null' => false, )
);
$xpdo_meta_map['Region']['composites']= array (
'user' => array('id' => array('local' => 'id', 'foreign' => 'city', 'cardinality' => 'one', ), ),
);
$xpdo_meta_map['Region']['aggregates']= array ();
$xpdo_meta_map['Region']= & $xpdo_meta_map['Region'];
what does the key of the composites array (’id’ above) signify? could i just change this so that I have the following:
$xpdo_meta_map['Region']['composites']= array (
'user' => array('city' => array('local' => 'id', 'foreign' => 'city', 'cardinality' => 'one'),
'region' => array('local' => 'id', 'foreign' => 'region', 'cardinality' => 'one')
)
);
also, what are aggregates and how are they different from composties?
as an aside, can i declare fields with a dbtype of ’UNSIGNED INT’ as with the parent above?
thanks for your help