[Dbix-class] insert

Nilson Santos Figueiredo Junior acid06 at gmail.com
Sat Jan 20 16:41:44 GMT 2007


On 1/20/07, Octavian Rasnita <orasnita at gmail.com> wrote:
> So first I need to insert the user, then to search the "user" table in order
> to get its ID, then loop and insert each role in the "role" table.
>
> Isn't there an easier method?

$schema->txn_do( sub {
  my $user = $schema->resultset('User')->create($user_data);
  $user->add_to_roles( $_ ) for @roles;
} );

Or something along these lines, according to your specific situation.

-Nilson Santos F. Jr.



More information about the Dbix-class mailing list