[horde] Problem in Rdo/RelationshipTest testing clotho example in MySQL

Elier Delgado elier.delgado at gmail.com
Fri Sep 4 03:44:22 UTC 2009


>> Hi Chuck,
>>
>> I was testing the Clotho example, all seem ok, just I see this problem:
>>
>> In RelationshipTest, if we have more than one availabilty for one resource,
>>
>> INSERT INTO `clotho_resource_availability` VALUES ('1', '1', '1121404095','2');
>> INSERT INTO `clotho_resource_availability` VALUES ('2', '1', '1121404096','3');
>>
>> The count in the asociated mapper do not work fine in this case:
>>
>> // one-to-many
>> echo "Resource ({$r->resource_id}) {$r->resource_name} has " .
>> count($r->availabilities) . " availabilities:";
>>
>> count($r->availabilities) = 1, when must be 2
>
> Looks like Jan's changes have already fixed this.
>
> -chuck

Yes, it seem solved, but configuration of relationships must be in
this way now to example can work.

class ItemMapper extends Clotho_Mapper {

    protected $_lazyRelationships = array(
        'parent' => array('type' => Horde_Rdo::ONE_TO_ONE,
                          'foreignKey' => 'item_parent',
                          'mapper' => 'ItemMapper'),

        'resources' => array('type' => Horde_Rdo::MANY_TO_MANY,
                             'mapper' => 'ResourceMapper',
                             'through' => 'clotho_wbs_resources')
    );


class ResourceAvailabilityMapper extends Clotho_Mapper {

    protected $_lazyRelationships = array(
        'resource' => array('type' => Horde_Rdo::MANY_TO_ONE,
                            'foreignKey' => 'resource_id',
                            'mapper' => 'ResourceMapper'),
        );

Somebody can comment when the relationship must be defined in
"_relationships" or in "_lazyRelationships" ?

Best regards, Elier


More information about the horde mailing list