Welcome Guest, Not a member yet? Register   Sign In
DataMapper saving multi-field join table
#1

[eluser]msteudel[/eluser]
I have the following tables:

Code:
Scenarios
id | scenario_name | etc.

Locations
id | location_name | etc.

Sites
id | site_name | etc.

Types
id | type_name | etc.

scenarios_sites
id | scenario_id | location_id | site_id | type_Id | created_on | updated_on

I'm trying to figure out how to save this sort of relationship ...

I tried something like this:

Code:
$site = new Site();
        $site->where( 'id', 3)->get();

        $loc = new Location();
        $loc->where( 'id', 4 )->get();

        $type = new Type();
        $type->where( 'id', 2 )->get();

        $scen = new Scenario();
        $scen->scenario_name = 'Test';
        $scen->save( array( $site, $loc, $type ) );

I get this error:

Code:
Unable to relate scenario with location.

Can anyone point me int he right direction.

TIA


Messages In This Thread
DataMapper saving multi-field join table - by El Forum - 02-01-2013, 04:27 PM
DataMapper saving multi-field join table - by El Forum - 02-01-2013, 04:42 PM
DataMapper saving multi-field join table - by El Forum - 02-01-2013, 04:52 PM
DataMapper saving multi-field join table - by El Forum - 02-03-2013, 02:45 PM
DataMapper saving multi-field join table - by El Forum - 02-03-2013, 09:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB