Hi,

Is it possible to insert in a table some records based on another resultset?

For example, I have just inserted a user in the "user" table, and then I want to insert the roles for this user in the "role" table.

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?

I have searched if there is an insert_related or something like this, but I couldn't find.

Anyway, if I still need to search the "user" table for getting the ID of the latest inserted user, isn't there another way of inserting the roles than one by one in a foreach loop?

I want to do something like:

insert into role values(1,2), (1,3), (1,4);

Thank you.

Octavian


_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to