3 DBIx::Class::Manual::SQLHackers::Transactions - DBIx::Class for SQL Hackers - DELETE
7 =item L<Introduction|DBIx::Class::Manual::SQLHackers::Introduction>
9 =item L<CREATE|DBIx::Class::Manual::SQLHackers::CREATE>
11 =item L<INSERT|DBIx::Class::Manual::SQLHackers::INSERT>
13 =item L<SELECT|DBIx::Class::Manual::SQLHackers::SELECT>
15 =item L<UPDATE|DBIx::Class::Manual::SQLHackers::UPDATE>
17 =item L<DELETE|DBIx::Class::Manual::SQLHackers::DELETE>
26 SELECT users.id, users.username FROM users WHERE id = 1;
27 UPDATE users SET username = 'fred' WHERE id = 1;
30 To create a transaction, put all your changes inside a coderef, and pass it to the B<txn_do> method on the Schema object. Transactions can also be safely nested,
31 in which case all but the top level transaction blocks become noops.
35 =item 1. Create a Schema object representing the database you are working with:
37 my $schema = MyDatabase::Schema->connect('dbi:SQLite:my.db');
39 =item 2. Call the B<txn_do> method on the Schema object:
41 $schema->txn_do( sub {
42 my $user = $schema->resultset('User')->find({ id => 1 });
44 $user->update({ username => 'fred' });