[Dbix-class] Updating foreign key does not reload related object

Matt S Trout dbix-class at trout.me.uk
Tue Aug 7 15:43:35 GMT 2007


On Tue, Aug 07, 2007 at 10:12:45AM +0000, Zbigniew Lukasiak wrote:
> On 8/3/07, Matt S Trout <dbix-class at trout.me.uk> wrote:
> > >
> > > I couldn't find in the documentation that this was possible. Is it also
> > > now possible to do
> > >
> > > my $obj = $schema->resultset('Event')->create({venue=>$existing_venue});
> >
> > Yep, although in that case I'd likely use $venue->events->create instead
> 
> Is that a replacement for $venue->create_related( 'events' ... )?

It's a more elegant equivalent.

You could also do

$venue->related_resultset('events')->create({...})

which is basically what both will call internally.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/                    http://www.shadowcat.co.uk/ 



More information about the DBIx-Class mailing list