On Sat, 20 Jan 2007, Octavian Rasnita wrote:
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.
Look harder. You want create_related, and yes, when called on the user
object, it does magically insert the correct user ID for you.
Jess
_______________________________________________
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]/